mirror of
https://github.com/less/less.js.git
synced 2026-04-09 03:00:20 -04:00
import interpolation finished. refactored the import phase to occur only within the import visitor - so that the import eval env can be passed between imports.
This commit is contained in:
@@ -249,26 +249,32 @@ function loadStyleSheet(sheet, callback, reload, remaining) {
|
||||
var timestamp = cache && cache.getItem(href + ':timestamp');
|
||||
var styles = { css: css, timestamp: timestamp };
|
||||
var env;
|
||||
var newFileInfo = {
|
||||
relativeUrls: less.relativeUrls,
|
||||
currentDirectory: hrefParts.path,
|
||||
filename: href
|
||||
};
|
||||
|
||||
if (sheet instanceof less.tree.parseEnv) {
|
||||
env = new less.tree.parseEnv(sheet);
|
||||
newFileInfo.entryPath = env.currentFileInfo.entryPath;
|
||||
newFileInfo.rootpath = env.currentFileInfo.rootpath;
|
||||
newFileInfo.rootFilename = env.currentFileInfo.rootFilename;
|
||||
} else {
|
||||
env = new less.tree.parseEnv(less);
|
||||
env.entryPath = hrefParts.path;
|
||||
env.mime = sheet.type;
|
||||
newFileInfo.entryPath = hrefParts.path;
|
||||
newFileInfo.rootpath = less.rootpath || hrefParts.path;
|
||||
newFileInfo.rootFilename = href;
|
||||
}
|
||||
|
||||
if (env.relativeUrls) {
|
||||
//todo - this relies on option being set on less object rather than being passed in as an option
|
||||
// - need an originalRootpath
|
||||
if (less.rootpath) {
|
||||
env.rootpath = extractUrlParts(less.rootpath + pathDiff(hrefParts.path, env.entryPath)).path;
|
||||
newFileInfo.rootpath = extractUrlParts(less.rootpath + pathDiff(hrefParts.path, newFileInfo.entryPath)).path;
|
||||
} else {
|
||||
env.rootpath = hrefParts.path;
|
||||
}
|
||||
} else {
|
||||
if (!less.rootpath) {
|
||||
env.rootpath = env.entryPath;
|
||||
newFileInfo.rootpath = hrefParts.path;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,8 +293,8 @@ function loadStyleSheet(sheet, callback, reload, remaining) {
|
||||
try {
|
||||
env.contents[href] = data; // Updating content cache
|
||||
env.paths = [hrefParts.path];
|
||||
env.filename = href;
|
||||
env.rootFilename = env.rootFilename || href;
|
||||
env.currentFileInfo = newFileInfo;
|
||||
|
||||
new(less.Parser)(env).parse(data, function (e, root) {
|
||||
if (e) { return callback(e, null, null, sheet); }
|
||||
try {
|
||||
@@ -296,7 +302,7 @@ function loadStyleSheet(sheet, callback, reload, remaining) {
|
||||
//TODO - there must be a better way? A generic less-to-css function that can both call error
|
||||
//and removeNode where appropriate
|
||||
//should also add tests
|
||||
if (env.rootFilename === href) {
|
||||
if (env.currentFileInfo.rootFilename === href) {
|
||||
removeNode(document.getElementById('less-error-message:' + extractId(href)));
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user