mirror of
https://github.com/less/less.js.git
synced 2026-05-01 03:00:22 -04:00
Allow replacing visitors to return undefined. Fixes #2252
This commit is contained in:
@@ -14,7 +14,7 @@ ToCSSVisitor.prototype = {
|
||||
|
||||
visitRule: function (ruleNode, visitArgs) {
|
||||
if (ruleNode.variable) {
|
||||
return [];
|
||||
return;
|
||||
}
|
||||
return ruleNode;
|
||||
},
|
||||
@@ -23,16 +23,14 @@ ToCSSVisitor.prototype = {
|
||||
// mixin definitions do not get eval'd - this means they keep state
|
||||
// so we have to clear that state here so it isn't used if toCSS is called twice
|
||||
mixinNode.frames = [];
|
||||
return [];
|
||||
},
|
||||
|
||||
visitExtend: function (extendNode, visitArgs) {
|
||||
return [];
|
||||
},
|
||||
|
||||
visitComment: function (commentNode, visitArgs) {
|
||||
if (commentNode.isSilent(this._context)) {
|
||||
return [];
|
||||
return;
|
||||
}
|
||||
return commentNode;
|
||||
},
|
||||
@@ -42,14 +40,14 @@ ToCSSVisitor.prototype = {
|
||||
visitArgs.visitDeeper = false;
|
||||
|
||||
if (!mediaNode.rules.length) {
|
||||
return [];
|
||||
return;
|
||||
}
|
||||
return mediaNode;
|
||||
},
|
||||
|
||||
visitDirective: function(directiveNode, visitArgs) {
|
||||
if (directiveNode.currentFileInfo.reference && !directiveNode.isReferenced) {
|
||||
return [];
|
||||
return;
|
||||
}
|
||||
if (directiveNode.name === "@charset") {
|
||||
// Only output the debug info together with subsequent @charset definitions
|
||||
@@ -61,7 +59,7 @@ ToCSSVisitor.prototype = {
|
||||
comment.debugInfo = directiveNode.debugInfo;
|
||||
return this._visitor.visit(comment);
|
||||
}
|
||||
return [];
|
||||
return;
|
||||
}
|
||||
this.charset = true;
|
||||
}
|
||||
|
||||
@@ -106,6 +106,7 @@ Visitor.prototype = {
|
||||
var out = [];
|
||||
for (i = 0; i < cnt; i++) {
|
||||
var evald = this.visit(nodes[i]);
|
||||
if (evald === undefined) { continue; }
|
||||
if (!evald.splice) {
|
||||
out.push(evald);
|
||||
} else if (evald.length) {
|
||||
@@ -124,6 +125,9 @@ Visitor.prototype = {
|
||||
|
||||
for (i = 0, cnt = arr.length; i < cnt; i++) {
|
||||
item = arr[i];
|
||||
if (item === undefined) {
|
||||
continue;
|
||||
}
|
||||
if (!item.splice) {
|
||||
out.push(item);
|
||||
continue;
|
||||
@@ -131,6 +135,9 @@ Visitor.prototype = {
|
||||
|
||||
for (j = 0, nestedCnt = item.length; j < nestedCnt; j++) {
|
||||
nestedItem = item[j];
|
||||
if (nestedItem === undefined) {
|
||||
continue;
|
||||
}
|
||||
if (!nestedItem.splice) {
|
||||
out.push(nestedItem);
|
||||
} else if (nestedItem.length) {
|
||||
|
||||
Reference in New Issue
Block a user