MCPcopy
hub / github.com/CodeboxIDE/codebox / loadStyleSheet

Function loadStyleSheet

core/cb.addons/require-tools/less/lessc.js:6755–6800  ·  view source on GitHub ↗
(sheet, callback, reload, remaining, newVars)

Source from the content-addressed store, hash-verified

6753}
6754
6755function loadStyleSheet(sheet, callback, reload, remaining, newVars) {
6756
6757 var env = new less.tree.parseEnv(less);
6758 env.mime = sheet.type;
6759
6760 if (newVars) {
6761 env.useFileCache = true;
6762 }
6763
6764 loadFile(sheet.href, null, function(e, data, path, newFileInfo, webInfo) {
6765
6766 if (webInfo) {
6767 webInfo.remaining = remaining;
6768
6769 var css = cache && cache.getItem(path),
6770 timestamp = cache && cache.getItem(path + ':timestamp');
6771
6772 if (!reload && timestamp && webInfo.lastModified &&
6773 (new(Date)(webInfo.lastModified).valueOf() ===
6774 new(Date)(timestamp).valueOf())) {
6775 // Use local copy
6776 createCSS(css, sheet);
6777 webInfo.local = true;
6778 callback(null, null, data, sheet, webInfo, path);
6779 return;
6780 }
6781 }
6782
6783 //TODO add tests around how this behaves when reloading
6784 removeError(path);
6785
6786 if (data) {
6787 env.currentFileInfo = newFileInfo;
6788 new(less.Parser)(env).parse(data, function (e, root) {
6789 if (e) { return callback(e, null, null, sheet); }
6790 try {
6791 callback(e, root, data, sheet, webInfo, path);
6792 } catch (e) {
6793 callback(e, null, null, sheet);
6794 }
6795 });
6796 } else {
6797 callback(e, null, null, sheet, webInfo, path);
6798 }
6799 }, env, newVars);
6800}
6801
6802function loadStyleSheets(callback, reload, newVars) {
6803 for (var i = 0; i < less.sheets.length; i++) {

Callers 1

loadStyleSheetsFunction · 0.85

Calls 4

createCSSFunction · 0.85
removeErrorFunction · 0.85
loadFileFunction · 0.70
callbackFunction · 0.50

Tested by

no test coverage detected