mirror of
https://github.com/less/less.js.git
synced 2026-05-01 03:00:22 -04:00
move action out of constructor
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user