Skip to content

Commit 2392e41

Browse files
committed
Fix index on mixed units error. Fixes #1228
1 parent dca9643 commit 2392e41

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

lib/less/tree/rule.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,16 @@ tree.Rule.prototype = {
2121
toCSS: function (env) {
2222
if (this.variable) { return "" }
2323
else {
24-
return this.name + (env.compress ? ':' : ': ') +
24+
try {
25+
return this.name + (env.compress ? ':' : ': ') +
2526
this.value.toCSS(env) +
2627
this.important + (this.inline ? "" : ";");
28+
}
29+
catch(e) {
30+
e.index = this.index;
31+
e.filename = this.currentFileInfo.filename;
32+
throw e;
33+
}
2734
}
2835
},
2936
eval: function (env) {
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
SyntaxError: Multiple units in dimension. Correct the units or use the unit function. Bad unit: px/em in {path}divide-mixed-units.less on line null, column 0:
2-
1 error: (1px / 3em);
1+
SyntaxError: Multiple units in dimension. Correct the units or use the unit function. Bad unit: px/em in {path}divide-mixed-units.less on line 2, column 3:
2+
1 .a {
3+
2 error: (1px / 3em);
4+
3 }
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/* Test */
2+
#blah {
3+
// blah
4+
}
15
.a {
26
error: (1px * 1em);
37
}
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
SyntaxError: Multiple units in dimension. Correct the units or use the unit function. Bad unit: em*px in {path}multiply-mixed-units.less on line null, column 0:
2-
1 error: (1px * 1em);
1+
SyntaxError: Multiple units in dimension. Correct the units or use the unit function. Bad unit: em*px in {path}multiply-mixed-units.less on line 6, column 3:
2+
5 .a {
3+
6 error: (1px * 1em);
4+
7 }

0 commit comments

Comments
 (0)