mirror of
https://github.com/less/less.js.git
synced 2026-04-09 03:00:20 -04:00
Fix - for some reason the flattening done by the import visitor is required
This commit is contained in:
@@ -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;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user