diff --git a/.gitignore b/.gitignore index f461f61dd..52a8aabf4 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ *~ .#* .idea +*.iml *.sublime-* # npm diff --git a/lib/less/tree/expression.js b/lib/less/tree/expression.js index 4f939a6f4..8773a4b4e 100644 --- a/lib/less/tree/expression.js +++ b/lib/less/tree/expression.js @@ -53,4 +53,9 @@ Expression.prototype.throwAwayComments = function () { return !(v instanceof Comment); }); }; +Expression.prototype.markReferenced = function () { + this.value.forEach(function (value) { + if (value.markReferenced) { value.markReferenced(); } + }); +}; module.exports = Expression; diff --git a/lib/less/tree/rule.js b/lib/less/tree/rule.js index cd2fe0c48..5b9d2c138 100644 --- a/lib/less/tree/rule.js +++ b/lib/less/tree/rule.js @@ -92,4 +92,22 @@ Rule.prototype.makeImportant = function () { this.index, this.currentFileInfo, this.inline); }; -module.exports = Rule; +// Recursive marking for rules +var mark = function(value) { + if (!Array.isArray(value)) { + if (value.markReferenced) { + value.markReferenced(); + } + } else { + value.forEach(function (ar) { + mark(ar); + }); + } +}; +Rule.prototype.markReferenced = function () { + if (this.value) { + mark(this.value); + } +}; + +module.exports = Rule; \ No newline at end of file diff --git a/test/css/import-reference.css b/test/css/import-reference.css index 7aa622c65..03e0fc039 100644 --- a/test/css/import-reference.css +++ b/test/css/import-reference.css @@ -59,7 +59,7 @@ div#id.class[a=1][b=2].class:not(1) { color: green; } .y { - pulled-in: yes; + pulled-in: yes /* inline comment survives */; } /* comment pulled in */ .visible { diff --git a/test/less/import/import-reference.less b/test/less/import/import-reference.less index cadf09f65..8f9002e8c 100644 --- a/test/less/import/import-reference.less +++ b/test/less/import/import-reference.less @@ -37,7 +37,7 @@ .zz { .y { - pulled-in: yes; + pulled-in: yes /* inline comment survives */; } /* comment pulled in */ }