fix, less with compression (-x) was unable to parse auto\9

This commit is contained in:
Luke Page
2013-03-06 16:06:16 +00:00
parent 900daaca59
commit 99aa363b70
5 changed files with 20 additions and 8 deletions

View File

@@ -1197,19 +1197,19 @@ less.Parser = function Parser(env) {
restore();
}
},
rule: function () {
rule: function (tryAnonymous) {
var name, value, c = input.charAt(i), important, match;
save();
if (c === '.' || c === '#' || c === '&') { return }
if (name = $(this.variable) || $(this.property)) {
if (!env.compress && (name.charAt(0) != '@') && (match = /^([^@+\/'"*`(;{}-]*);/.exec(chunks[j]))) {
i += match[0].length - 1;
value = new(tree.Anonymous)(match[1]);
} else {
value = $(this.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 || (name.charAt(0) === '@')) ?
($(this.value) || $(this.anonymousValue)) :
($(this.anonymousValue) || $(this.value));
important = $(this.important);
if (value && $(this.end)) {
@@ -1217,9 +1217,18 @@ less.Parser = function Parser(env) {
} else {
furthest = i;
restore();
if (value && !tryAnonymous) {
return this.rule(true);
}
}
}
},
anonymousValue: function () {
if (match = /^([^@+\/'"*`(;{}-]*);/.exec(chunks[j])) {
i += match[0].length - 1;
return new(tree.Anonymous)(match[1]);
}
},
//
// An @import directive

View File

@@ -1,2 +1,2 @@
#colours{color1:#fea;color2:#fea;color3:rgba(255,238,170,0.1);string:"#ffeeaa"}
dimensions{val:.1px;val:0;val:4cm;val:.2;val:5;angles-must-have-unit:0deg}
dimensions{val:.1px;val:0;val:4cm;val:.2;val:5;angles-must-have-unit:0deg;width:auto\9}

View File

@@ -74,6 +74,7 @@ p + h1 {
background: -webkit-gradient(linear, left top, left bottom, from(#ff0000), to(#0000ff));
margin: ;
filter: alpha(opacity=100);
width: auto\9;
}
.misc .nested-multiple {
multiple-semi-colons: yes;

View File

@@ -12,4 +12,5 @@ dimensions {
val: 0.2;
val: 5;
angles-must-have-unit: 0deg;
width: auto\9;
}

View File

@@ -85,6 +85,7 @@ p + h1 {
multiple-semi-colons: yes;;;;;;
};
filter: alpha(opacity=100);
width: auto\9;
}
#important {