From bf9c59025bab7401299e8feb3bb26b3b039499c0 Mon Sep 17 00:00:00 2001 From: Luke Page Date: Fri, 21 Feb 2014 11:03:38 +0000 Subject: [PATCH] Fixed that in some situations a mixin call into a referenced file wouldn't import media queries. Fixes #1469 --- lib/less/tree/media.js | 1 + test/css/import-reference.css | 27 ++++++++++++++++++++++---- test/less/import-reference.less | 11 +++++++---- test/less/import/import-reference.less | 8 ++++++++ 4 files changed, 39 insertions(+), 8 deletions(-) diff --git a/lib/less/tree/media.js b/lib/less/tree/media.js index 4531cf4cd..095e43e88 100644 --- a/lib/less/tree/media.js +++ b/lib/less/tree/media.js @@ -74,6 +74,7 @@ tree.Media.prototype = { }, markReferenced: function () { var i, rules = this.rules[0].rules; + this.rules[0].markReferenced(); this.isReferenced = true; for (i = 0; i < rules.length; i++) { if (rules[i].markReferenced) { diff --git a/test/css/import-reference.css b/test/css/import-reference.css index d61df816a..f25f4b1dc 100644 --- a/test/css/import-reference.css +++ b/test/css/import-reference.css @@ -1,7 +1,17 @@ -/* - The media statement above is invalid (no selector) - We should ban invalid media queries with properties and no selector? -*/ +input[type="text"].class#id[attr=32]:not(1) { + color: white; +} +div#id.class[a=1][b=2].class:not(1) { + color: white; +} +@media print { + .class { + color: blue; + } + .class .sub { + width: 42; + } +} .visible { color: red; } @@ -47,3 +57,12 @@ .visible { extend: test; } +.test-mediaq-import { + color: green; + test: 340px; +} +@media (max-size: 450px) { + .test-mediaq-import { + color: red; + } +} diff --git a/test/less/import-reference.less b/test/less/import-reference.less index cf9da168f..93160ab5d 100644 --- a/test/less/import-reference.less +++ b/test/less/import-reference.less @@ -1,10 +1,6 @@ @import (reference) url("import-once.less"); @import (reference) url("css-3.less"); @import (reference) url("media.less"); -/* - The media statement above is invalid (no selector) - We should ban invalid media queries with properties and no selector? -*/ @import (reference) url("import/import-reference.less"); .b { @@ -15,4 +11,11 @@ .visible:extend(.z all) { extend: test; +} + +.test-mediaq-import { + .mixin-with-mediaq(340px); +} + +.class:extend(.class all) { } \ No newline at end of file diff --git a/test/less/import/import-reference.less b/test/less/import/import-reference.less index 9eac45fcb..c77f692e7 100644 --- a/test/less/import/import-reference.less +++ b/test/less/import/import-reference.less @@ -40,4 +40,12 @@ pulled-in: yes; } /* comment pulled in */ +} +@max-size: 450px; +.mixin-with-mediaq(@num) { + color: green; + test: @num; + @media (max-size: @max-size) { + color: red; + } } \ No newline at end of file