start seperating browser load stylesheet and loadFile

This commit is contained in:
Luke Page
2013-03-19 10:50:35 +00:00
parent c2adad8341
commit 806ddb64e6
2 changed files with 12 additions and 3 deletions

View File

@@ -248,6 +248,15 @@ function extractUrlParts(url, baseUrl) {
}
function loadStyleSheet(sheet, callback, reload, remaining) {
loadFile(sheet, function(e, root, data, sheet, webInfo, path) {
if (webInfo) {
webInfo.remaining = remaining;
}
callback(e, root, data, sheet, webInfo, path);
}, reload);
}
function loadFile(sheet, callback, reload) {
// sheet may be set to the stylesheet for the initial load or a collection of properties including
// some env variables for imports
@@ -295,7 +304,7 @@ function loadStyleSheet(sheet, callback, reload, remaining) {
new(Date)(styles.timestamp).valueOf())) {
// Use local copy
createCSS(styles.css, sheet);
callback(null, null, data, sheet, { local: true, remaining: remaining }, href);
callback(null, null, data, sheet, { local: true }, href);
} else {
// Use remote copy (re-parse)
try {
@@ -306,7 +315,7 @@ function loadStyleSheet(sheet, callback, reload, remaining) {
new(less.Parser)(env).parse(data, function (e, root) {
if (e) { return callback(e, null, null, sheet); }
try {
callback(e, root, data, sheet, { local: false, lastModified: lastModified, remaining: remaining }, href);
callback(e, root, data, sheet, { local: false, lastModified: lastModified }, href);
//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

View File

@@ -1611,7 +1611,7 @@ if (less.mode === 'browser' || less.mode === 'rhino') {
// as we need this to evaluate the current stylesheet.
loadStyleSheet(sheetEnv,
function (e, root, data, sheet, _, path) {
callback.call(null, e, root, path);
callback(e, root, path);
}, true);
};
}