Bug 1275546 - Use CSS lexer to parse angle values in css-angle.js . r=nchevobbe

MozReview-Commit-ID: DVqlbrruf2b
This commit is contained in:
Sebastin Santy
2016-07-08 06:29:00 +02:00
parent ad9d1c6399
commit 3e0753b8da
3 changed files with 57 additions and 2 deletions

View File

@@ -10,6 +10,8 @@ const SPECIALVALUES = new Set([
"unset"
]);
const {getCSSLexer} = require("devtools/shared/css-lexer");
/**
* This module is used to convert between various angle units.
*
@@ -66,7 +68,12 @@ CssAngle.prototype = {
},
get valid() {
return /^-?\d+\.?\d*(deg|rad|grad|turn)$/gi.test(this.authored);
let token = getCSSLexer(this.authored).nextToken();
if (!token) {
return false;
}
return (token.tokenType === "dimension"
&& token.text.toLowerCase() in CssAngle.ANGLEUNIT);
},
get specialValue() {