mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1049436 - Stop showing color swatch for CSS vars r=bgrins
This commit is contained in:
parent
545ae6c276
commit
788952244d
@ -54,6 +54,22 @@ function testParseCssProperty() {
|
||||
|
||||
target.innerHTML = "";
|
||||
|
||||
testParseCssVar();
|
||||
}
|
||||
|
||||
function testParseCssVar() {
|
||||
let frag = parser.parseCssProperty("color", "var(--some-kind-of-green)", {
|
||||
colorSwatchClass: "test-colorswatch"
|
||||
});
|
||||
|
||||
let target = doc.querySelector("div");
|
||||
ok(target, "captain, we have the div");
|
||||
target.appendChild(frag);
|
||||
|
||||
is(target.innerHTML, "var(--some-kind-of-green)", "CSS property correctly parsed");
|
||||
|
||||
target.innerHTML = "";
|
||||
|
||||
testParseHTMLAttribute();
|
||||
}
|
||||
|
||||
|
@ -14,9 +14,14 @@ const MAX_ITERATIONS = 100;
|
||||
const REGEX_QUOTES = /^".*?"|^".*|^'.*?'|^'.*/;
|
||||
const REGEX_WHITESPACE = /^\s+/;
|
||||
const REGEX_FIRST_WORD_OR_CHAR = /^\w+|^./;
|
||||
const REGEX_CSS_PROPERTY_VALUE = /(^[^;]+)/;
|
||||
const REGEX_CUBIC_BEZIER = /^linear|^ease-in-out|^ease-in|^ease-out|^ease|^cubic-bezier\(([0-9.\- ]+,){3}[0-9.\- ]+\)/;
|
||||
|
||||
// CSS variable names are identifiers which the spec defines as follows:
|
||||
// In CSS, identifiers (including element names, classes, and IDs in
|
||||
// selectors) can contain only the characters [a-zA-Z0-9] and ISO 10646
|
||||
// characters U+00A0 and higher, plus the hyphen (-) and the underscore (_).
|
||||
const REGEX_CSS_VAR = /\bvar\(\s*--[-_a-zA-Z0-9\u00A0-\u10FFFF]+\s*\)/;
|
||||
|
||||
/**
|
||||
* This regex matches:
|
||||
* - #F00
|
||||
@ -188,6 +193,15 @@ OutputParser.prototype = {
|
||||
continue;
|
||||
}
|
||||
|
||||
matched = text.match(REGEX_CSS_VAR);
|
||||
if (matched) {
|
||||
let match = matched[0];
|
||||
|
||||
text = this._trimMatchFromStart(text, match);
|
||||
this._appendTextNode(match);
|
||||
continue;
|
||||
}
|
||||
|
||||
matched = text.match(REGEX_WHITESPACE);
|
||||
if (matched) {
|
||||
let match = matched[0];
|
||||
|
Loading…
Reference in New Issue
Block a user