mirror of
https://github.com/less/less.js.git
synced 2026-04-09 03:00:20 -04:00
remove @media code from tree.Directive
This commit is contained in:
@@ -1,14 +1,10 @@
|
||||
(function (tree) {
|
||||
|
||||
tree.Directive = function (name, value, features) {
|
||||
var selectors;
|
||||
|
||||
this.name = name;
|
||||
this.features = features && new(tree.Value)(features);
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
selectors = name === '@media' ? [new(tree.Selector)([new(tree.Element)('&', null, 0)])] : [];
|
||||
this.ruleset = new(tree.Ruleset)(selectors, value);
|
||||
this.ruleset = new(tree.Ruleset)([], value);
|
||||
this.ruleset.allowImports = true;
|
||||
} else {
|
||||
this.value = value;
|
||||
@@ -16,11 +12,9 @@ tree.Directive = function (name, value, features) {
|
||||
};
|
||||
tree.Directive.prototype = {
|
||||
toCSS: function (ctx, env) {
|
||||
var features = this.features ? ' ' + this.features.toCSS(env) : '';
|
||||
|
||||
if (this.ruleset) {
|
||||
this.ruleset.root = ctx.length === 0 || (this.name !== '@media');
|
||||
return this.name + features + (env.compress ? '{' : ' {\n ') +
|
||||
this.ruleset.root = true;
|
||||
return this.name + (env.compress ? '{' : ' {\n ') +
|
||||
this.ruleset.toCSS(ctx, env).trim().replace(/\n/g, '\n ') +
|
||||
(env.compress ? '}': '\n}\n');
|
||||
} else {
|
||||
@@ -28,7 +22,6 @@ tree.Directive.prototype = {
|
||||
}
|
||||
},
|
||||
eval: function (env) {
|
||||
this.features = this.features && this.features.eval(env);
|
||||
env.frames.unshift(this);
|
||||
this.ruleset = this.ruleset && this.ruleset.eval(env);
|
||||
env.frames.shift();
|
||||
|
||||
@@ -71,7 +71,7 @@ tree.Import.prototype = {
|
||||
[i, 1].concat(ruleset.rules[i].eval(env)));
|
||||
}
|
||||
}
|
||||
return this.features ? new(tree.Directive)('@media', ruleset.rules, this.features.value) : ruleset.rules;
|
||||
return this.features ? new(tree.Media)(ruleset.rules, this.features.value) : ruleset.rules;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user