mirror of
https://github.com/less/less.js.git
synced 2026-04-09 03:00:20 -04:00
Move parsing into loadStylesheet from loadFile
This commit is contained in:
@@ -248,11 +248,23 @@ function extractUrlParts(url, baseUrl) {
|
||||
}
|
||||
|
||||
function loadStyleSheet(sheet, callback, reload, remaining) {
|
||||
loadFile(sheet, function(e, root, data, sheet, webInfo, path) {
|
||||
loadFile(sheet, function(e, root, data, sheet, webInfo, path, env) {
|
||||
if (webInfo) {
|
||||
webInfo.remaining = remaining;
|
||||
}
|
||||
callback(e, root, data, sheet, webInfo, path);
|
||||
|
||||
if (data) {
|
||||
new(less.Parser)(env).parse(data, function (e, root) {
|
||||
if (e) { return callback(e, null, null, sheet); }
|
||||
try {
|
||||
callback(e, root, data, sheet, webInfo, path);
|
||||
} catch (e) {
|
||||
callback(e, null, null, sheet);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
callback(e, root, data, sheet, webInfo, path);
|
||||
}
|
||||
}, reload);
|
||||
}
|
||||
|
||||
@@ -312,20 +324,14 @@ function loadFile(sheet, callback, reload) {
|
||||
env.paths = [hrefParts.path];
|
||||
env.currentFileInfo = newFileInfo;
|
||||
|
||||
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 }, 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
|
||||
if (env.currentFileInfo.rootFilename === href) {
|
||||
removeNode(document.getElementById('less-error-message:' + extractId(href)));
|
||||
}
|
||||
} catch (e) {
|
||||
callback(e, null, null, sheet);
|
||||
}
|
||||
});
|
||||
//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 (newFileInfo.rootFilename === href) {
|
||||
removeNode(document.getElementById('less-error-message:' + extractId(href)));
|
||||
}
|
||||
|
||||
callback(null, null, data, sheet, { local: false, lastModified: lastModified }, href, env)
|
||||
} catch (e) {
|
||||
callback(e, null, null, sheet);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user