Skip to content

Commit bf9c590

Browse files
committed
Fixed that in some situations a mixin call into a referenced file wouldn't import media queries. Fixes #1469
1 parent 6d5473e commit bf9c590

File tree

4 files changed

+39
-8
lines changed

4 files changed

+39
-8
lines changed

lib/less/tree/media.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ tree.Media.prototype = {
7474
},
7575
markReferenced: function () {
7676
var i, rules = this.rules[0].rules;
77+
this.rules[0].markReferenced();
7778
this.isReferenced = true;
7879
for (i = 0; i < rules.length; i++) {
7980
if (rules[i].markReferenced) {

test/css/import-reference.css

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1-
/*
2-
The media statement above is invalid (no selector)
3-
We should ban invalid media queries with properties and no selector?
4-
*/
1+
input[type="text"].class#id[attr=32]:not(1) {
2+
color: white;
3+
}
4+
div#id.class[a=1][b=2].class:not(1) {
5+
color: white;
6+
}
7+
@media print {
8+
.class {
9+
color: blue;
10+
}
11+
.class .sub {
12+
width: 42;
13+
}
14+
}
515
.visible {
616
color: red;
717
}
@@ -47,3 +57,12 @@
4757
.visible {
4858
extend: test;
4959
}
60+
.test-mediaq-import {
61+
color: green;
62+
test: 340px;
63+
}
64+
@media (max-size: 450px) {
65+
.test-mediaq-import {
66+
color: red;
67+
}
68+
}

test/less/import-reference.less

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
@import (reference) url("import-once.less");
22
@import (reference) url("css-3.less");
33
@import (reference) url("media.less");
4-
/*
5-
The media statement above is invalid (no selector)
6-
We should ban invalid media queries with properties and no selector?
7-
*/
84
@import (reference) url("import/import-reference.less");
95

106
.b {
@@ -15,4 +11,11 @@
1511

1612
.visible:extend(.z all) {
1713
extend: test;
14+
}
15+
16+
.test-mediaq-import {
17+
.mixin-with-mediaq(340px);
18+
}
19+
20+
.class:extend(.class all) {
1821
}

test/less/import/import-reference.less

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,12 @@
4040
pulled-in: yes;
4141
}
4242
/* comment pulled in */
43+
}
44+
@max-size: 450px;
45+
.mixin-with-mediaq(@num) {
46+
color: green;
47+
test: @num;
48+
@media (max-size: @max-size) {
49+
color: red;
50+
}
4351
}

0 commit comments

Comments
 (0)