Skip to content

Commit a1862fe

Browse files
committed
Properly exit calc mode after use (#3493)
1 parent 49ccd10 commit a1862fe

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

lib/less/contexts.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ contexts.Eval.prototype.enterCalc = function () {
7474

7575
contexts.Eval.prototype.exitCalc = function () {
7676
this.calcStack.pop();
77-
if (!this.calcStack) {
77+
if (!this.calcStack.length) {
7878
this.inCalc = false;
7979
}
8080
};

test/css/calc.css

+9
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,12 @@
1717
.c {
1818
height: calc(100% - ((10px * 3) + (10px * 2)));
1919
}
20+
.correctly-exit-calc-mode h2 {
21+
width: 10px;
22+
}
23+
.correctly-exit-calc-mode div {
24+
width: calc(100px * 2);
25+
}
26+
.correctly-exit-calc-mode h1 {
27+
color: white;
28+
}

test/less/calc.less

+17-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,20 @@
2727
.c {
2828
@v: 10px;
2929
height: calc(100% - ((@v * 3) + (@v * 2)));
30-
}
30+
}
31+
32+
.correctly-exit-calc-mode {
33+
@a: 10;
34+
h2 { width: unit(@a, px); }
35+
36+
div { width: calc(100px * 2); }
37+
38+
.mk-map() {
39+
text: white;
40+
background: black;
41+
}
42+
43+
@p: .mk-map();
44+
45+
h1 { color: @p[text]; }
46+
}

test/sourcemaps/custom-props.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":3,"sources":["testweb/sourcemaps/custom-props.less"],"names":[],"mappings":"AAEA;EACC,uBAHO,UAGP;EACA,OAAO,eAAP;EACA,gCAAA","file":"sourcemaps/custom-props.css"}
1+
{"version":3,"sources":["testweb/sourcemaps/custom-props.less"],"names":[],"mappings":"AAEA;EACC,uBAHO,UAGP;EACA,OAAO,eAAP;EACA,sBALO,UAKP","file":"sourcemaps/custom-props.css"}

0 commit comments

Comments
 (0)