mirror of
https://github.com/less/less.js.git
synced 2026-04-09 03:00:20 -04:00
start seperating browser load stylesheet and loadFile
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user