diff --git a/lib/less/browser.js b/lib/less/browser.js index 0d777fd4..0be96213 100644 --- a/lib/less/browser.js +++ b/lib/less/browser.js @@ -252,7 +252,7 @@ function loadStyleSheet(sheet, callback, reload, remaining) { var env = new less.tree.parseEnv(less); env.mime = sheet.type; - loadFile(sheet, env, null, function(e, data, sheet, webInfo, path, newFileInfo) { + loadFile(sheet.href, null, function(e, data, path, newFileInfo, webInfo) { if (webInfo) { webInfo.remaining = remaining; @@ -286,18 +286,18 @@ function loadStyleSheet(sheet, callback, reload, remaining) { } else { callback(e, null, null, sheet, webInfo, path); } - }, reload); + }, env); } -function loadFile(sheet, env, currentFileInfo, callback) { +function loadFile(originalHref, currentFileInfo, callback, env) { - if (currentFileInfo && currentFileInfo.currentDirectory && !/^([a-z-]+:)?\//.test(sheet.href)) { - sheet.href = currentFileInfo.currentDirectory + sheet.href; + if (currentFileInfo && currentFileInfo.currentDirectory && !/^([a-z-]+:)?\//.test(originalHref)) { + originalHref = currentFileInfo.currentDirectory + originalHref; } // sheet may be set to the stylesheet for the initial load or a collection of properties including // some env variables for imports - var hrefParts = extractUrlParts(sheet.href, window.location.href); + var hrefParts = extractUrlParts(originalHref, window.location.href); var href = hrefParts.url; var newFileInfo = { currentDirectory: hrefParts.path, @@ -324,18 +324,18 @@ function loadFile(sheet, env, currentFileInfo, callback) { } } - xhr(href, sheet.type, function (data, lastModified) { + xhr(href, env.mime, function (data, lastModified) { // Store data this session session_cache += data.replace(/@import .+?;/ig, ''); // Use remote copy (re-parse) try { - callback(null, data, sheet, { lastModified: lastModified }, href, newFileInfo) + callback(null, data, href, newFileInfo, { lastModified: lastModified }) } catch (e) { - callback(e, null, sheet); + callback(e); } }, function (status, url) { - callback({ type: 'File', message: "'" + url + "' wasn't found (" + status + ")" }, null, sheet); + callback({ type: 'File', message: "'" + url + "' wasn't found (" + status + ")" }); }); } diff --git a/lib/less/parser.js b/lib/less/parser.js index 478c78e4..2f919f09 100644 --- a/lib/less/parser.js +++ b/lib/less/parser.js @@ -1608,10 +1608,10 @@ if (less.mode === 'browser' || less.mode === 'rhino') { // less.Parser.fileLoader = function (path, currentFileInfo, callback, env) { - loadFile({href: path, type: env.mime }, env, currentFileInfo, - function (e, data, sheet, webInfo, path, newFileInfo) { + loadFile(path, currentFileInfo, + function (e, data, path, newFileInfo) { callback(e, data, path, newFileInfo); - }); + }, env); }; }