[Pkg-javascript-commits] [less.js] 233/285: Fix - for some reason the flattening done by the import visitor is required

Jonas Smedegaard dr at jones.dk
Mon Oct 26 23:23:57 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 5f1f0911683cb30ecbfa53d37143bca574650378
Author: Luke Page <luke.a.page at gmail.com>
Date:   Fri Oct 24 07:20:32 2014 +0100

    Fix - for some reason the flattening done by the import visitor is required
---
 lib/less/visitors/import-visitor.js | 35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/lib/less/visitors/import-visitor.js b/lib/less/visitors/import-visitor.js
index 1855dcd..b19ec7a 100644
--- a/lib/less/visitors/import-visitor.js
+++ b/lib/less/visitors/import-visitor.js
@@ -15,7 +15,7 @@ var ImportVisitor = function(importer, finish) {
 };
 
 ImportVisitor.prototype = {
-    isReplacing: false,
+    isReplacing: true,
     run: function (root) {
         var error;
         try {
@@ -36,25 +36,19 @@ ImportVisitor.prototype = {
 
         if (!importNode.css || inlineCSS) {
 
+            var context = new contexts.Eval(this.context, this.context.frames.slice(0));
+            var importParent = context.frames[0];
+
             // TODO - process this type of imports *last*
             //if (importNode.isVariableImport()) {
             //    console.log("variable import detected");
             //}
-            var context = new contexts.Eval(this.context, this.context.frames.slice(0));
-
-            var importParent = context.frames[0];
-            var newImportNode = this.processImportNode(importNode, context);
-            for(var i = 0; i < importParent.rules.length; i++) {
-                if (importParent.rules[i] === importNode) {
-                    importParent.rules[i] = newImportNode;
-                    break;
-                }
-            }
+            importNode = this.processImportNode(importNode, context, importParent);
         }
         visitArgs.visitDeeper = false;
         return importNode;
     },
-    processImportNode: function(importNode, context) {
+    processImportNode: function(importNode, context, importParent) {
         var evaldImportNode,
             inlineCSS = importNode.options.inline;
 
@@ -69,20 +63,27 @@ ImportVisitor.prototype = {
         }
 
         if (evaldImportNode && (!evaldImportNode.css || inlineCSS)) {
-            importNode = evaldImportNode;
             this.importCount++;
 
-            if (importNode.options.multiple) {
+            if (evaldImportNode.options.multiple) {
                 context.importMultiple = true;
             }
 
             // try appending if we haven't determined if it is css or not
-            var tryAppendLessExtension = importNode.css === undefined;
+            var tryAppendLessExtension = evaldImportNode.css === undefined;
 
-            var onImported = this.onImported.bind(this, importNode, context),
+            var onImported = this.onImported.bind(this, evaldImportNode, context),
                 sequencedOnImported = this._sequencer.addImport(onImported);
 
-            this._importer.push(importNode.getPath(), tryAppendLessExtension, importNode.currentFileInfo, importNode.options, sequencedOnImported);
+            this._importer.push(evaldImportNode.getPath(), tryAppendLessExtension, evaldImportNode.currentFileInfo, evaldImportNode.options, sequencedOnImported);
+
+            for(var i = 0; i < importParent.rules.length; i++) {
+                if (importParent.rules[i] === importNode) {
+                    importParent.rules[i] = evaldImportNode;
+                    break;
+                }
+            }
+            importNode = evaldImportNode;
         }
         return importNode;
     },

-- 
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