mirror of
https://github.com/less/less.js.git
synced 2026-05-01 03:00:22 -04:00
added @media bubbling (similar to SASS)
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
(function (tree) {
|
||||
|
||||
tree.Directive = function (name, value, features) {
|
||||
var selectors;
|
||||
|
||||
this.name = name;
|
||||
this.features = features && new(tree.Value)(features);
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
this.ruleset = new(tree.Ruleset)([], value);
|
||||
selectors = name === '@media' ? [new(tree.Selector)([new(tree.Element)("", null, 0)])] : [];
|
||||
this.ruleset = new(tree.Ruleset)(selectors, value);
|
||||
this.ruleset.allowImports = true;
|
||||
} else {
|
||||
this.value = value;
|
||||
@@ -16,7 +19,7 @@ tree.Directive.prototype = {
|
||||
var features = this.features ? ' ' + this.features.toCSS(env) : '';
|
||||
|
||||
if (this.ruleset) {
|
||||
this.ruleset.root = true;
|
||||
this.ruleset.root = ctx.length === 0 || (this.name !== '@media');
|
||||
return this.name + features + (env.compress ? '{' : ' {\n ') +
|
||||
this.ruleset.toCSS(ctx, env).trim().replace(/\n/g, '\n ') +
|
||||
(env.compress ? '}': '\n}\n');
|
||||
|
||||
Reference in New Issue
Block a user