From d70769bfb7372b07c8cc58b3ab9e754c09e0990d Mon Sep 17 00:00:00 2001 From: Luke Page Date: Sat, 16 Feb 2013 14:44:58 +0000 Subject: [PATCH] variables in media queries in import statements --- lib/less/parser.js | 1 + lib/less/tree/import.js | 8 ++++---- test/css/import.css | 2 ++ test/less/import.less | 3 +++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/less/parser.js b/lib/less/parser.js index 8d8d33af..0642f351 100644 --- a/lib/less/parser.js +++ b/lib/less/parser.js @@ -1196,6 +1196,7 @@ less.Parser = function Parser(env) { if (dir && (path = $(this.entities.quoted) || $(this.entities.url))) { features = $(this.mediaFeatures); if ($(';')) { + features = features && new(tree.Value)(features); var importOnce = dir[1] !== 'multiple'; return new(tree.Import)(path, imports, features, importOnce, index, env.rootpath); } diff --git a/lib/less/tree/import.js b/lib/less/tree/import.js index ac10888c..50702ffb 100644 --- a/lib/less/tree/import.js +++ b/lib/less/tree/import.js @@ -17,7 +17,7 @@ tree.Import = function (path, imports, features, once, index, rootpath) { this.once = once; this.index = index; this._path = path; - this.features = features && new(tree.Value)(features); + this.features = features; this.rootpath = rootpath; // The '.less' extension is optional @@ -33,7 +33,7 @@ tree.Import = function (path, imports, features, once, index, rootpath) { if (! this.css) { imports.push(this.path, function (e, root, imported) { if (e) { e.index = index; } - if (imported && that.once) that.skip = imported; + if (imported && that.once) { that.skip = imported; } that.root = root || new(tree.Ruleset)([], []); }); } @@ -65,10 +65,10 @@ tree.Import.prototype = { eval: function (env) { var ruleset, features = this.features && this.features.eval(env); - if (this.skip) return []; + if (this.skip) { return []; } if (this.css) { - return this; + return new(tree.Import)(this._path, null, features, this.once, this.index, this.rootpath); } else { ruleset = new(tree.Ruleset)([], this.root.rules.slice(0)); diff --git a/test/css/import.css b/test/css/import.css index 3ed7de53..7e1a11e9 100644 --- a/test/css/import.css +++ b/test/css/import.css @@ -1,6 +1,8 @@ @import url(http://fonts.googleapis.com/css?family=Open+Sans); @import url(something.css) screen and (color) and (max-width: 600px); + +@import url("file.css") (min-width: 100px); #import-test { height: 10px; color: #ff0000; diff --git a/test/less/import.less b/test/less/import.less index 33b1ff62..547e5cad 100644 --- a/test/less/import.less +++ b/test/less/import.less @@ -2,6 +2,9 @@ @import url(something.css) screen and (color) and (max-width: 600px); +@var: 100px; +@import url("file.css") (min-width:@var); + #import-test { .mixin; width: 10px;