[Pkg-javascript-commits] [less.js] 234/285: sequencer logic for variable import
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 5202a1fc5f2b101e188274491fbf4fc58debc330
Author: Luke Page <luke.a.page at gmail.com>
Date: Fri Oct 24 07:29:45 2014 +0100
sequencer logic for variable import
---
lib/less/visitors/import-sequencer.js | 25 +++++++++++++++++++------
lib/less/visitors/import-visitor.js | 11 ++++++++---
2 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/lib/less/visitors/import-sequencer.js b/lib/less/visitors/import-sequencer.js
index 6fb4639..779faf9 100644
--- a/lib/less/visitors/import-sequencer.js
+++ b/lib/less/visitors/import-sequencer.js
@@ -1,5 +1,6 @@
function ImportSequencer(onSequencerEmpty) {
this.imports = [];
+ this.variableImports = [];
this._onSequencerEmpty = onSequencerEmpty;
}
@@ -18,14 +19,26 @@ ImportSequencer.prototype.addImport = function(callback) {
};
};
+ImportSequencer.prototype.addVariableImport = function(callback) {
+ this.variableImports.push(callback);
+};
+
ImportSequencer.prototype.tryRun = function() {
- while(this.imports.length > 0) {
- var importItem = this.imports[0];
- if (!importItem.isReady) {
- return;
+ while(true) {
+ while(this.imports.length > 0) {
+ var importItem = this.imports[0];
+ if (!importItem.isReady) {
+ return;
+ }
+ this.imports = this.imports.slice(1);
+ importItem.callback.apply(null, importItem.args);
+ }
+ if (this.variableImports.length === 0) {
+ break;
}
- this.imports = this.imports.slice(1);
- importItem.callback.apply(null, importItem.args);
+ var variableImport = this.variableImports[0];
+ this.variableImports = this.variableImports.slice(1);
+ variableImport();
}
if (this._onSequencerEmpty) {
this._onSequencerEmpty();
diff --git a/lib/less/visitors/import-visitor.js b/lib/less/visitors/import-visitor.js
index b19ec7a..9b8e4b2 100644
--- a/lib/less/visitors/import-visitor.js
+++ b/lib/less/visitors/import-visitor.js
@@ -27,6 +27,7 @@ ImportVisitor.prototype = {
}
this.isFinished = true;
+ this._sequencer.tryRun();
if (this.importCount === 0) {
this._finish(error || this.error);
}
@@ -113,9 +114,13 @@ ImportVisitor.prototype = {
var subFinish = function(e) {
importVisitor.importCount--;
- if (importVisitor.importCount === 0 && importVisitor.isFinished) {
- importVisitor._finish(e || importVisitor.error);
- } else if (e) {
+ if (importVisitor.isFinished) {
+ this._sequencer.tryRun();
+ if (importVisitor.importCount === 0) {
+ importVisitor._finish(e || importVisitor.error);
+ }
+ }
+ if (e) {
importVisitor.error = e;
}
};
--
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