8000 media-query can now be a variable · rusongyu/less.js@9f9eeec · GitHub
[go: up one dir, main page]

Skip to content

Commit 9f9eeec

Browse files
committed
media-query can now be a variable
1 parent d17a461 commit 9f9eeec

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

lib/less/parser.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,11 +1074,18 @@ less.Parser = function Parser(env) {
10741074
},
10751075

10761076
mediaFeatures: function () {
1077-
var f, features = [];
1078-
while (f = $(this.mediaFeature)) {
1079-
features.push(f);
1080-
if (! $(',')) { break }
1081-
}
1077+
var features = [];
1078+
1079+
do {
1080+
if (e = $(this.mediaFeature)) {
1081+
features.push(e);
1082+
if (! $(',')) { break }
1083+
} else if (e = $(this.entities.variable)) {
1084+
features.push(e);
1085+
if (! $(',')) { break }
1086+
}
1087+
} while (e);
1088+
10821089
return features.length > 0 ? features : null;
10831090
},
10841091

test/css/media.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@
2525
max-width: 480px;
2626
}
2727
}
28+
@media only screen and (max-width: 200px) {
29+
width: 480px;
30+
}

test/less/media.less

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
@media print {
77
.class {
8-
color: blue;
8+
color: blue;
99
.sub {
1010
width: @var;
1111
}
@@ -29,3 +29,8 @@
2929
max-width: 480px;
3030
}
3131
}
32+
33+
@smartphone: ~"only screen and (max-width: 200px)";
34+
@media @smartphone {
35+
width: 480px;
36+
}

0 commit comments

Comments
 (0)
0