move action out of constructor

This commit is contained in:
Luke Page
2013-03-01 14:50:38 +00:00
parent c1095a7218
commit 59a443556a
2 changed files with 15 additions and 12 deletions

View File

@@ -1,22 +1,23 @@
(function (tree) {
tree.importVisitor = function(root, importer, finish, evalEnv) {
tree.importVisitor = function(importer, finish, evalEnv) {
this._visitor = new tree.visitor(this);
this._importer = importer;
this._finish = finish;
this.env = evalEnv || new tree.evalEnv();
this.importCount = 0;
// process the contents
this._visitor.visit(root);
this.isFinished = true;
if (this.importCount === 0) {
this._finish();
}
};
tree.importVisitor.prototype = {
run: function (root) {
// process the contents
this._visitor.visit(root);
this.isFinished = true;
if (this.importCount === 0) {
this._finish();
}
},
visitImport: function (importNode, visitArgs) {
var importVisitor = this,
evaldImportNode;
@@ -51,7 +52,8 @@
if (root) {
importNode.root = root;
new(tree.importVisitor)(root, importVisitor._importer, subFinish, env);
new(tree.importVisitor)(importVisitor._importer, subFinish, env)
.run(root);
} else {
subFinish();
}

View File

@@ -470,7 +470,8 @@ less.Parser = function Parser(env) {
if (env.processImports !== false) {
try {
new tree.importVisitor(root, this.imports, finish);
new tree.importVisitor(this.imports, finish)
.run(root);
}
catch(e) {
error = e;