seperate sheet and env

This commit is contained in:
Luke Page
2013-03-19 12:00:56 +00:00
parent ede491b02d
commit c391e72c5e
4 changed files with 13 additions and 21 deletions

View File

@@ -248,7 +248,12 @@ function extractUrlParts(url, baseUrl) {
}
function loadStyleSheet(sheet, callback, reload, remaining) {
loadFile(sheet, function(e, data, sheet, webInfo, path, env) {
var env = new less.tree.parseEnv(less);
env.mime = sheet.type;
env.currentFileInfo = null;
loadFile(sheet, env, function(e, data, sheet, webInfo, path, env) {
if (webInfo) {
webInfo.remaining = remaining;
}
@@ -268,7 +273,7 @@ function loadStyleSheet(sheet, callback, reload, remaining) {
}, reload);
}
function loadFile(sheet, callback, reload) {
function loadFile(sheet, env, callback, reload) {
// sheet may be set to the stylesheet for the initial load or a collection of properties including
// some env variables for imports
@@ -277,21 +282,18 @@ function loadFile(sheet, callback, reload) {
var css = cache && cache.getItem(href);
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);
if (env.currentFileInfo) {
env = new less.tree.parseEnv(env);
newFileInfo.entryPath = env.currentFileInfo.entryPath;
newFileInfo.rootpath = env.currentFileInfo.rootpath;
newFileInfo.rootFilename = env.currentFileInfo.rootFilename;
} else {
env = new less.tree.parseEnv(less);
env.mime = sheet.type;
newFileInfo.entryPath = hrefParts.path;
newFileInfo.rootpath = less.rootpath || hrefParts.path;
newFileInfo.rootFilename = href;