[Pkg-javascript-commits] [less.js] 251/285: Allow replacing visitors to return undefined. Fixes #2252

Jonas Smedegaard dr at jones.dk
Mon Oct 26 23:23:59 UTC 2015


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag v2.0.0
in repository less.js.

commit 8faa5b83d9f78e4587620305577676c09c7c4485
Author: Luke Page <luke.a.page at gmail.com>
Date:   Sat Nov 1 17:31:50 2014 +0000

    Allow replacing visitors to return undefined. Fixes #2252
---
 lib/less/visitors/to-css-visitor.js | 12 +++++-------
 lib/less/visitors/visitor.js        |  7 +++++++
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/lib/less/visitors/to-css-visitor.js b/lib/less/visitors/to-css-visitor.js
index 6965898..3e26f88 100644
--- a/lib/less/visitors/to-css-visitor.js
+++ b/lib/less/visitors/to-css-visitor.js
@@ -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;
         }
diff --git a/lib/less/visitors/visitor.js b/lib/less/visitors/visitor.js
index 5c0b5a5..afa05d7 100644
--- a/lib/less/visitors/visitor.js
+++ b/lib/less/visitors/visitor.js
@@ -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) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/less.js.git



More information about the Pkg-javascript-commits mailing list