[Pkg-javascript-commits] [less.js] 03/05: Fix backtracking on multiplication to support dimension /|* keyword, with or without strict maths. Fixes #2066.
Jonas Smedegaard
dr at jones.dk
Mon Oct 26 23:22:52 UTC 2015
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag v1.7.3
in repository less.js.
commit fc26d5c77e519bb83c2c61f7c49b1d0ee4c3683f
Author: Luke Page <luke.a.page at gmail.com>
Date: Sun Jun 22 11:23:33 2014 +0100
Fix backtracking on multiplication to support dimension /|* keyword, with or without strict maths. Fixes #2066.
---
lib/less/parser.js | 58 ++++++++++++++++++++++++++++------------------------
test/css/css-3.css | 3 +++
test/less/css-3.less | 6 +++++-
3 files changed, 39 insertions(+), 28 deletions(-)
diff --git a/lib/less/parser.js b/lib/less/parser.js
index 7159fa2..d3c6ce6 100644
--- a/lib/less/parser.js
+++ b/lib/less/parser.js
@@ -405,8 +405,8 @@ less.Parser = function Parser(env) {
switch (cc) {
case 40: // (
- parenLevel++;
- lastOpeningParen = parserCurrentIndex;
+ parenLevel++;
+ lastOpeningParen = parserCurrentIndex;
continue;
case 41: // )
if (--parenLevel < 0) {
@@ -417,8 +417,8 @@ less.Parser = function Parser(env) {
if (!parenLevel) { emitChunk(); }
continue;
case 123: // {
- level++;
- lastOpening = parserCurrentIndex;
+ level++;
+ lastOpening = parserCurrentIndex;
continue;
case 125: // }
if (--level < 0) {
@@ -517,7 +517,7 @@ less.Parser = function Parser(env) {
var evaldRoot,
css,
evalEnv = new tree.evalEnv(options);
-
+
//
// Allows setting variables with a hash, so:
//
@@ -964,7 +964,7 @@ less.Parser = function Parser(env) {
colorCandidateString = colorCandidateString[1];
if (!colorCandidateString.match(/^[A-Fa-f0-9]+$/)) { // verify if candidate consists only of allowed HEX characters
error("Invalid HEX color code");
- }
+ }
return new(tree.Color)(rgb[1]);
}
},
@@ -1043,8 +1043,8 @@ less.Parser = function Parser(env) {
rulesetCall: function () {
var name;
- if (input.charAt(i) === '@' && (name = $re(/^(@[\w-]+)\s*\(\s*\)\s*;/))) {
- return new tree.RulesetCall(name[1]);
+ if (input.charAt(i) === '@' && (name = $re(/^(@[\w-]+)\s*\(\s*\)\s*;/))) {
+ return new tree.RulesetCall(name[1]);
}
},
@@ -1071,7 +1071,7 @@ less.Parser = function Parser(env) {
if (extendList) { extendList.push(extend); } else { extendList = [ extend ]; }
} while($char(","));
-
+
expect(/^\)/);
if (isRule) {
@@ -1087,7 +1087,7 @@ less.Parser = function Parser(env) {
extendRule: function() {
return this.extend(true);
},
-
+
//
// Mixins
//
@@ -1293,7 +1293,7 @@ less.Parser = function Parser(env) {
variadic = argInfo.variadic;
// .mixincall("@{a}");
- // looks a bit like a mixin definition..
+ // looks a bit like a mixin definition..
// also
// .mixincall(@a: {rule: set;});
// so we have to be nice and restore
@@ -1302,7 +1302,7 @@ less.Parser = function Parser(env) {
restore();
return;
}
-
+
parsers.comments();
if ($re(/^when/)) { // Guard
@@ -1409,7 +1409,7 @@ less.Parser = function Parser(env) {
//
combinator: function () {
var c = input.charAt(i);
-
+
if (c === '>' || c === '+' || c === '~' || c === '|' || c === '^') {
i++;
if (input.charAt(i) === '^') {
@@ -1502,7 +1502,7 @@ less.Parser = function Parser(env) {
}
return block;
},
-
+
detachedRuleset: function() {
var blockRuleset = this.blockRuleset();
if (blockRuleset) {
@@ -1515,7 +1515,7 @@ less.Parser = function Parser(env) {
//
ruleset: function () {
var selectors, s, rules, debugInfo;
-
+
save();
if (env.dumpLineNumbers) {
@@ -1562,20 +1562,20 @@ less.Parser = function Parser(env) {
name = this.variable() || this.ruleProperty();
if (name) {
isVariable = typeof name === "string";
-
+
if (isVariable) {
value = this.detachedRuleset();
}
-
+
if (!value) {
// prefer to try to parse first if its a variable or we are compressing
// but always fallback on the other one
value = !tryAnonymous && (env.compress || isVariable) ?
(this.value() || this.anonymousValue()) :
(this.anonymousValue() || this.value());
-
+
important = this.important();
-
+
// a name returned by this.ruleProperty() is always an array of the form:
// [string-1, ..., string-n, ""] or [string-1, ..., string-n, "+"]
// where each item is a tree.Keyword or tree.Variable
@@ -1756,7 +1756,7 @@ less.Parser = function Parser(env) {
save();
name = $re(/^@[a-z-]+/);
-
+
if (!name) { return; }
nonVendorSpecificName = name;
@@ -1829,7 +1829,7 @@ less.Parser = function Parser(env) {
if (rules || (!hasBlock && value && $char(';'))) {
forget();
- return new(tree.Directive)(name, value, rules, index, env.currentFileInfo,
+ return new(tree.Directive)(name, value, rules, index, env.currentFileInfo,
env.dumpLineNumbers ? getDebugInfo(index, input, env) : null);
}
@@ -1886,13 +1886,17 @@ less.Parser = function Parser(env) {
if (peek(/^\/[*\/]/)) {
break;
}
+
+ save();
+
op = $char('/') || $char('*');
- if (!op) { break; }
+ if (!op) { forget(); break; }
a = this.operand();
- if (!a) { break; }
+ if (!a) { restore(); break; }
+ forget();
m.parensInOp = true;
a.parensInOp = true;
@@ -1916,7 +1920,7 @@ less.Parser = function Parser(env) {
if (!a) {
break;
}
-
+
m.parensInOp = true;
a.parensInOp = true;
operation = new(tree.Operation)(op, [operation || m, a], isSpaced);
@@ -2023,7 +2027,7 @@ less.Parser = function Parser(env) {
},
ruleProperty: function () {
var c = current, name = [], index = [], length = 0, s, k;
-
+
function match(re) {
var a = re.exec(c);
if (a) {
@@ -2037,7 +2041,7 @@ less.Parser = function Parser(env) {
match(/^(\*?)/);
while (match(/^((?:[\w-]+)|(?:@\{[\w-]+\}))/)); // !
if ((name.length > 1) && match(/^\s*((?:\+_|\+)?)\s*:/)) {
- // at last, we have the complete match now. move forward,
+ // at last, we have the complete match now. move forward,
// convert name particles to tree objects and return:
skipWhitespace(length);
if (name[0] === '') {
@@ -2048,7 +2052,7 @@ less.Parser = function Parser(env) {
s = name[k];
name[k] = (s.charAt(0) !== '@')
? new(tree.Keyword)(s)
- : new(tree.Variable)('@' + s.slice(2, -1),
+ : new(tree.Variable)('@' + s.slice(2, -1),
index[k], env.currentFileInfo);
}
return name;
diff --git a/test/css/css-3.css b/test/css/css-3.css
index 61f635c..4dd7243 100644
--- a/test/css/css-3.css
+++ b/test/css/css-3.css
@@ -127,3 +127,6 @@ h1 {
body ^^ .shadow {
display: done;
}
+#issue2066 {
+ background: url('/images/icon-team.svg') 0 0 / contain;
+}
diff --git a/test/less/css-3.less b/test/less/css-3.less
index 06a5d2c..c054dc4 100644
--- a/test/less/css-3.less
+++ b/test/less/css-3.less
@@ -126,4 +126,8 @@ h1 { color: green; }
.shadow ^ .dom,
body ^^ .shadow {
display: done;
-}
\ No newline at end of file
+}
+
+#issue2066 {
+ background: url('/images/icon-team.svg') 0 0 / contain;
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/less.js.git
More information about the Pkg-javascript-commits
mailing list