mirror of
https://github.com/less/less.js.git
synced 2026-01-22 21:58:14 -05:00
rename import silent to import mute. Fixes #1210
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
- support for import inline option to include css that you do not want less to parse e.g. `@import (inline) "file.css";`
|
||||
- better support for modifyVars (refresh styles with new variables, using a file cache), is now more resiliant
|
||||
- support for import silent option to reference external css, but not output it. Any mixin calls or extend's will be output.
|
||||
- support for import mute option to reference external css, but not output it. Any mixin calls or extend's will be output.
|
||||
|
||||
# 1.4.1
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// 'currentDirectory' - path to the current file, absolute
|
||||
// 'rootFilename' - filename of the base file
|
||||
// 'entryPath' - absolute path to the entry file
|
||||
// 'silent' - whether the file should be silent and only output parts that are referenced
|
||||
// 'mute' - whether the file should be mute and only output parts that are referenced
|
||||
|
||||
tree.parseEnv = function(options) {
|
||||
copyFromOriginal(options, this, parseCopyProperties);
|
||||
|
||||
@@ -83,7 +83,7 @@ var less = {
|
||||
},
|
||||
writeError: function (ctx, options) {
|
||||
options = options || {};
|
||||
if (options.silent) { return }
|
||||
if (options.silent) { return; }
|
||||
sys.error(less.formatError(ctx, options));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -106,8 +106,8 @@ less.Parser = function Parser(env) {
|
||||
newEnv.processImports = false;
|
||||
newEnv.contents[fullPath] = contents;
|
||||
|
||||
if (currentFileInfo.silent || importOptions.silent) {
|
||||
newFileInfo.silent = true;
|
||||
if (currentFileInfo.mute || importOptions.mute) {
|
||||
newFileInfo.mute = true;
|
||||
}
|
||||
|
||||
if (importOptions.inline) {
|
||||
@@ -1321,7 +1321,7 @@ less.Parser = function Parser(env) {
|
||||
},
|
||||
|
||||
importOption: function() {
|
||||
var opt = $(/^(less|css|multiple|once|inline|silent)/);
|
||||
var opt = $(/^(less|css|multiple|once|inline|mute)/);
|
||||
if (opt) {
|
||||
return opt[1];
|
||||
}
|
||||
|
||||
@@ -8,11 +8,11 @@ tree.Comment = function (value, silent, index, currentFileInfo) {
|
||||
tree.Comment.prototype = {
|
||||
type: "Comment",
|
||||
toCSS: function (env) {
|
||||
return (env.compress || (this.currentFileInfo && this.currentFileInfo.silent && !this.isNotSilent)) ? '' : this.value;
|
||||
return (env.compress || (this.currentFileInfo && this.currentFileInfo.mute && !this.isNotMute)) ? '' : this.value;
|
||||
},
|
||||
eval: function () { return this; },
|
||||
markNotSilent: function () {
|
||||
this.isNotSilent = true;
|
||||
markNotMute: function () {
|
||||
this.isNotMute = true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ tree.Directive.prototype = {
|
||||
},
|
||||
toCSS: function (env) {
|
||||
|
||||
if (this.currentFileInfo.silent && !this.isNotSilent) {
|
||||
if (this.currentFileInfo.mute && !this.isNotMute) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -45,14 +45,14 @@ tree.Directive.prototype = {
|
||||
variable: function (name) { return tree.Ruleset.prototype.variable.call(this.ruleset, name) },
|
||||
find: function () { return tree.Ruleset.prototype.find.apply(this.ruleset, arguments) },
|
||||
rulesets: function () { return tree.Ruleset.prototype.rulesets.apply(this.ruleset) },
|
||||
markNotSilent: function () {
|
||||
markNotMute: function () {
|
||||
var rule, i;
|
||||
this.isNotSilent = true;
|
||||
this.isNotMute = true;
|
||||
if (this.ruleset) {
|
||||
for (i = 0; i < this.ruleset.rules.length; i++) {
|
||||
rule = this.ruleset.rules[i];
|
||||
if (rule.markNotSilent) {
|
||||
rule.markNotSilent();
|
||||
if (rule.markNotMute) {
|
||||
rule.markNotMute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,13 +72,13 @@ tree.Media.prototype = {
|
||||
var el = new(tree.Element)('', '&', 0);
|
||||
return [new(tree.Selector)([el], null, this.index, this.currentFileInfo)];
|
||||
},
|
||||
markNotSilent: function () {
|
||||
markNotMute: function () {
|
||||
var rule, i;
|
||||
this.isNotSilent = true;
|
||||
this.isNotMute = true;
|
||||
for (i = 0; i < this.ruleset.rules.length; i++) {
|
||||
rule = this.ruleset.rules[i];
|
||||
if (rule.markNotSilent) {
|
||||
rule.markNotSilent();
|
||||
if (rule.markNotMute) {
|
||||
rule.markNotMute();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -49,11 +49,11 @@ tree.mixin.Call.prototype = {
|
||||
}
|
||||
}
|
||||
if (match) {
|
||||
if (!this.currentFileInfo || !this.currentFileInfo.silent) {
|
||||
if (!this.currentFileInfo || !this.currentFileInfo.mute) {
|
||||
for (i = 0; i < rules.length; i++) {
|
||||
rule = rules[i];
|
||||
if (rule.markNotSilent) {
|
||||
rule.markNotSilent();
|
||||
if (rule.markNotMute) {
|
||||
rule.markNotMute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,7 +245,7 @@ tree.Ruleset.prototype = {
|
||||
.filter(function(p) {
|
||||
var i;
|
||||
for(i = 0; i < p.length; i++) {
|
||||
if (!p[i].isSilent()) {
|
||||
if (!p[i].isMute()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -278,9 +278,9 @@ tree.Ruleset.prototype = {
|
||||
return css.join('') + (env.compress ? '\n' : '');
|
||||
},
|
||||
|
||||
markNotSilent: function () {
|
||||
markNotMute: function () {
|
||||
for (var s = 0; s < this.selectors.length; s++) {
|
||||
this.selectors[s].markNotSilent();
|
||||
this.selectors[s].markNotMute();
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
(function (tree) {
|
||||
|
||||
tree.Selector = function (elements, extendList, index, currentFileInfo, isNotSilent) {
|
||||
tree.Selector = function (elements, extendList, index, currentFileInfo, isNotMute) {
|
||||
this.elements = elements;
|
||||
this.extendList = extendList || [];
|
||||
this.currentFileInfo = currentFileInfo || {};
|
||||
this.isNotSilent = isNotSilent;
|
||||
this.isNotMute = isNotMute;
|
||||
};
|
||||
tree.Selector.prototype = {
|
||||
type: "Selector",
|
||||
@@ -13,7 +13,7 @@ tree.Selector.prototype = {
|
||||
this.extendList = visitor.visit(this.extendList)
|
||||
},
|
||||
createDerived: function(elements, extendList) {
|
||||
return new(tree.Selector)(elements, extendList || this.extendList, this.index, this.currentFileInfo, this.isNotSilent);
|
||||
return new(tree.Selector)(elements, extendList || this.extendList, this.index, this.currentFileInfo, this.isNotMute);
|
||||
},
|
||||
match: function (other) {
|
||||
var elements = this.elements,
|
||||
@@ -62,11 +62,11 @@ tree.Selector.prototype = {
|
||||
|
||||
return this._css;
|
||||
},
|
||||
markNotSilent: function () {
|
||||
this.isNotSilent = true;
|
||||
markNotMute: function () {
|
||||
this.isNotMute = true;
|
||||
},
|
||||
isSilent: function() {
|
||||
return this.currentFileInfo.silent && !this.isNotSilent;
|
||||
isMute: function() {
|
||||
return this.currentFileInfo.mute && !this.isNotMute;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
@import (silent) url("import-once.less");
|
||||
@import (silent) url("css-3.less");
|
||||
@import (silent) url("media.less");
|
||||
@import (mute) url("import-once.less");
|
||||
@import (mute) url("css-3.less");
|
||||
@import (mute) url("media.less");
|
||||
/*
|
||||
The media statement above is invalid (no selector)
|
||||
We should ban invalid media queries with properties and no selector?
|
||||
*/
|
||||
@import (silent) url("import/import-silent.less");
|
||||
@import (mute) url("import/import-mute.less");
|
||||
|
||||
.b {
|
||||
.z();
|
||||
Reference in New Issue
Block a user