parent
5a4e1290d3
commit
70a827b033
|
@ -599,7 +599,7 @@ function addAppliesTo(list, name, value) {
|
||||||
list.removeChild(list.firstChild);
|
list.removeChild(list.firstChild);
|
||||||
}
|
}
|
||||||
let e;
|
let e;
|
||||||
if (name && value) {
|
if (name) {
|
||||||
e = template.appliesTo.cloneNode(true);
|
e = template.appliesTo.cloneNode(true);
|
||||||
$('[name=applies-type]', e).value = name;
|
$('[name=applies-type]', e).value = name;
|
||||||
$('[name=applies-value]', e).value = value;
|
$('[name=applies-value]', e).value = value;
|
||||||
|
|
|
@ -44,24 +44,25 @@ var mozParser = (() => {
|
||||||
lastSection.code = '';
|
lastSection.code = '';
|
||||||
}
|
}
|
||||||
for (const f of e.functions) {
|
for (const f of e.functions) {
|
||||||
const m = f && f.match(/^([\w-]*)\((['"]?)(.+?)\2?\)$/);
|
const m = f && f.match(/^([\w-]*)\((.+?)\)$/);
|
||||||
if (!m || !/^(url|url-prefix|domain|regexp)$/.test(m[1])) {
|
if (!m || !/^(url|url-prefix|domain|regexp)$/.test(m[1])) {
|
||||||
errors.push(`${e.line}:${e.col + 1} invalid function "${m ? m[1] : f || ''}"`);
|
errors.push(`${e.line}:${e.col + 1} invalid function "${m ? m[1] : f || ''}"`);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const aType = CssToProperty[m[1]];
|
const aType = CssToProperty[m[1]];
|
||||||
const aValue = aType !== 'regexps' ? m[3] : m[3].replace(/\\\\/g, '\\');
|
const aValue = unquote(aType !== 'regexps' ? m[2] : m[2].replace(/\\\\/g, '\\'));
|
||||||
(section[aType] = section[aType] || []).push(aValue);
|
(section[aType] = section[aType] || []).push(aValue);
|
||||||
}
|
}
|
||||||
sectionStack.push(section);
|
sectionStack.push(section);
|
||||||
});
|
});
|
||||||
|
|
||||||
parser.addListener('enddocument', function () {
|
parser.addListener('enddocument', e => {
|
||||||
const end = backtrackTo(this, parserlib.css.Tokens.RBRACE, 'start');
|
|
||||||
const section = sectionStack.pop();
|
const section = sectionStack.pop();
|
||||||
const lastSection = sectionStack[sectionStack.length - 1];
|
const lastSection = sectionStack[sectionStack.length - 1];
|
||||||
|
const end = {line: e.line, col: e.col - 1};
|
||||||
section.code += getRange(section.start, end);
|
section.code += getRange(section.start, end);
|
||||||
lastSection.start = (++end.col, end);
|
end.col += 2;
|
||||||
|
lastSection.start = end;
|
||||||
doAddSection(section);
|
doAddSection(section);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -119,6 +120,11 @@ var mozParser = (() => {
|
||||||
}
|
}
|
||||||
sections.push(Object.assign({}, section));
|
sections.push(Object.assign({}, section));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function unquote(s) {
|
||||||
|
const first = s.charAt(0);
|
||||||
|
return (first === '"' || first === "'") && s.endsWith(first) ? s.slice(1, -1) : s;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user