mirror of
https://github.com/less/less.js.git
synced 2026-04-09 03:00:20 -04:00
move selector joining into visitor
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
(function (tree) {
|
||||
tree.joinSelectorVisitor = function() {
|
||||
this.context = [];
|
||||
this.contexts = [[]];
|
||||
this._visitor = new tree.visitor(this);
|
||||
};
|
||||
|
||||
@@ -18,16 +18,23 @@
|
||||
},
|
||||
|
||||
visitRuleset: function (rulesetNode, visitArgs) {
|
||||
var context = this.contexts[this.contexts.length - 1];
|
||||
var paths = [];
|
||||
this.contexts.push(paths);
|
||||
|
||||
if (! rulesetNode.root) {
|
||||
rulesetNode.joinSelectors(paths, context, rulesetNode.selectors);
|
||||
rulesetNode.paths = paths;
|
||||
}
|
||||
return rulesetNode;
|
||||
},
|
||||
visitMedia: function (rulesetNode, visitArgs) {
|
||||
|
||||
return rulesetNode;
|
||||
visitRulesetOut: function (rulesetNode) {
|
||||
this.contexts.length = this.contexts.length - 1;
|
||||
},
|
||||
visitDirective: function (rulesetNode, visitArgs) {
|
||||
|
||||
return rulesetNode;
|
||||
visitMedia: function (mediaNode, visitArgs) {
|
||||
var context = this.contexts[this.contexts.length - 1];
|
||||
mediaNode.ruleset.root = (context.length === 0 || context[0].multiMedia);
|
||||
return mediaNode;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ tree.Media.prototype = {
|
||||
toCSS: function (ctx, env) {
|
||||
var features = this.features.toCSS(env);
|
||||
|
||||
this.ruleset.root = (ctx.length === 0 || ctx[0].multiMedia);
|
||||
return '@media ' + features + (env.compress ? '{' : ' {\n ') +
|
||||
this.ruleset.toCSS(ctx, env).trim().replace(/\n/g, '\n ') +
|
||||
(env.compress ? '}': '\n}\n');
|
||||
|
||||
@@ -186,10 +186,6 @@ tree.Ruleset.prototype = {
|
||||
debugInfo, // Line number debugging
|
||||
rule;
|
||||
|
||||
if (! this.root) {
|
||||
this.joinSelectors(paths, context, this.selectors);
|
||||
}
|
||||
|
||||
// Compile rules and rulesets
|
||||
for (var i = 0; i < this.rules.length; i++) {
|
||||
rule = this.rules[i];
|
||||
@@ -249,7 +245,7 @@ tree.Ruleset.prototype = {
|
||||
} else {
|
||||
if (rules.length > 0) {
|
||||
debugInfo = tree.debugInfo(env, this);
|
||||
selector = paths.map(function (p) {
|
||||
selector = this.paths.map(function (p) {
|
||||
return p.map(function (s) {
|
||||
return s.toCSS(env);
|
||||
}).join('').trim();
|
||||
|
||||
Reference in New Issue
Block a user