Bug 1049436 - Stop showing color swatch for CSS vars r=bgrins

This commit is contained in:
Michael Ratcliffe 2014-12-26 11:40:35 +00:00
parent 9e8143334d
commit e1602a6fb5
2 changed files with 31 additions and 1 deletions

View File

@ -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();
}

View File

@ -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];