Skip to content

Commit 6f7676a

Browse files
committed
Merge pull request #2173 from seven-phases-max/master
Property interpolation fix for `@*` values
2 parents e045362 + 36383dc commit 6f7676a

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

lib/less/tree/rule.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
(function (tree) {
22

3-
tree.Rule = function (name, value, important, merge, index, currentFileInfo, inline) {
3+
tree.Rule = function (name, value, important, merge, index, currentFileInfo, inline, variable) {
44
this.name = name;
55
this.value = (value instanceof tree.Value || value instanceof tree.Ruleset) ? value : new(tree.Value)([value]);
66
this.important = important ? ' ' + important.trim() : '';
77
this.merge = merge;
88
this.index = index;
99
this.currentFileInfo = currentFileInfo;
1010
this.inline = inline || false;
11-
this.variable = name.charAt && (name.charAt(0) === '@');
11+
this.variable = (variable !== undefined) ? variable
12+
: (name.charAt && (name.charAt(0) === '@'));
1213
};
1314

1415
tree.Rule.prototype = {
@@ -30,13 +31,14 @@ tree.Rule.prototype = {
3031
},
3132
toCSS: tree.toCSS,
3233
eval: function (env) {
33-
var strictMathBypass = false, name = this.name, evaldValue;
34+
var strictMathBypass = false, name = this.name, variable = this.variable, evaldValue;
3435
if (typeof name !== "string") {
3536
// expand 'primitive' name directly to get
3637
// things faster (~10% for benchmark.less):
3738
name = (name.length === 1)
3839
&& (name[0] instanceof tree.Keyword)
3940
? name[0].value : evalName(env, name);
41+
variable = false; // never treat expanded interpolation as new variable name
4042
}
4143
if (name === "font" && !env.strictMath) {
4244
strictMathBypass = true;
@@ -54,7 +56,8 @@ tree.Rule.prototype = {
5456
evaldValue,
5557
this.important,
5658
this.merge,
57-
this.index, this.currentFileInfo, this.inline);
59+
this.index, this.currentFileInfo, this.inline,
60+
variable);
5861
}
5962
catch(e) {
6063
if (typeof e.index !== 'number') {

test/css/property-name-interp.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
pi-test {
22
border: 0;
3+
@not-variable: @not-variable;
34
ufo-width: 50%;
45
*-z-border: 1px dashed blue;
56
-www-border-top: 2px;

test/less/property-name-interp.less

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ pi-test {
66
@c_c: left;
77
@d-d4: radius;
88
@-: -;
9-
9+
10+
@var: ~'@not-variable';
11+
1012
@{a}: 0;
13+
@{var}: @var;
1114
@{prefix}width: 50%;
1215
*-z-@{a} :1px dashed blue;
1316
-www-@{a}-@{bb}: 2px;

0 commit comments

Comments
 (0)