[Pkg-javascript-commits] [less.js] 235/285: use structure to run variable imports last
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 e1c28d635863eeefbf1fa56194461beababff789
Author: Luke Page <luke.a.page at gmail.com>
Date: Fri Oct 24 13:07:31 2014 +0100
use structure to run variable imports last
---
lib/less/visitors/import-visitor.js | 44 ++++++++++++++++++-------------------
1 file changed, 21 insertions(+), 23 deletions(-)
diff --git a/lib/less/visitors/import-visitor.js b/lib/less/visitors/import-visitor.js
index 9b8e4b2..14b5b97 100644
--- a/lib/less/visitors/import-visitor.js
+++ b/lib/less/visitors/import-visitor.js
@@ -40,11 +40,12 @@ ImportVisitor.prototype = {
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");
- //}
- importNode = this.processImportNode(importNode, context, importParent);
+ this.importCount++;
+ if (importNode.isVariableImport()) {
+ this._sequencer.addVariableImport(this.processImportNode.bind(this, importNode, context, importParent));
+ } else {
+ importNode = this.processImportNode(importNode, context, importParent);
+ }
}
visitArgs.visitDeeper = false;
return importNode;
@@ -64,7 +65,6 @@ ImportVisitor.prototype = {
}
if (evaldImportNode && (!evaldImportNode.css || inlineCSS)) {
- this.importCount++;
if (evaldImportNode.options.multiple) {
context.importMultiple = true;
@@ -85,12 +85,17 @@ ImportVisitor.prototype = {
}
}
importNode = evaldImportNode;
+ } else {
+ this.importCount--;
}
return importNode;
},
onImported: function (importNode, context, e, root, importedAtRoot, fullPath) {
- if (e && !e.filename) {
- e.index = importNode.index; e.filename = importNode.currentFileInfo.filename;
+ if (e) {
+ if (!e.filename) {
+ e.index = importNode.index; e.filename = importNode.currentFileInfo.filename;
+ }
+ this.error = e;
}
var importVisitor = this,
@@ -111,20 +116,6 @@ ImportVisitor.prototype = {
}
}
- var subFinish = function(e) {
- importVisitor.importCount--;
-
- if (importVisitor.isFinished) {
- this._sequencer.tryRun();
- if (importVisitor.importCount === 0) {
- importVisitor._finish(e || importVisitor.error);
- }
- }
- if (e) {
- importVisitor.error = e;
- }
- };
-
if (root) {
importNode.root = root;
importNode.importedFilename = fullPath;
@@ -143,7 +134,14 @@ ImportVisitor.prototype = {
}
}
- subFinish();
+ importVisitor.importCount--;
+
+ if (importVisitor.isFinished) {
+ this._sequencer.tryRun();
+ if (importVisitor.importCount === 0) {
+ importVisitor._finish(importVisitor.error);
+ }
+ }
},
visitRule: function (ruleNode, visitArgs) {
visitArgs.visitDeeper = false;
--
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