mirror of
https://github.com/less/less.js.git
synced 2026-05-01 03:00:22 -04:00
@@ -26,6 +26,7 @@ require("./log-listener")(less, options);
|
||||
var errors = require("./error-reporting")(window, less, options);
|
||||
var browser = require("./browser");
|
||||
var cache = options.cache || require("./cache")(window, options, less.logger);
|
||||
var PromiseConstructor = typeof Promise === 'undefined' ? require('promise') : Promise;
|
||||
|
||||
options.env = options.env || (window.location.hostname == '127.0.0.1' ||
|
||||
window.location.hostname == '0.0.0.0' ||
|
||||
@@ -222,16 +223,23 @@ if (/!watch/.test(location.hash)) {
|
||||
//
|
||||
// Get all <link> tags with the 'rel' attribute set to "stylesheet/less"
|
||||
//
|
||||
var links = document.getElementsByTagName('link');
|
||||
less.registerStylesheets = function(callback) {
|
||||
return new PromiseConstructor(function(resolve, reject) {
|
||||
var links = document.getElementsByTagName('link');
|
||||
less.sheets = [];
|
||||
|
||||
less.sheets = [];
|
||||
for (var i = 0; i < links.length; i++) {
|
||||
if (links[i].rel === 'stylesheet/less' || (links[i].rel.match(/stylesheet/) &&
|
||||
(links[i].type.match(typePattern)))) {
|
||||
less.sheets.push(links[i]);
|
||||
}
|
||||
|
||||
for (var i = 0; i < links.length; i++) {
|
||||
if (links[i].rel === 'stylesheet/less' || (links[i].rel.match(/stylesheet/) &&
|
||||
(links[i].type.match(typePattern)))) {
|
||||
less.sheets.push(links[i]);
|
||||
}
|
||||
}
|
||||
if (i === links.length - 1) {
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
//
|
||||
// With this function, it's possible to alter variables and re-render
|
||||
@@ -269,4 +277,8 @@ less.refresh = function (reload, modifyVars) {
|
||||
|
||||
less.refreshStyles = loadStyles;
|
||||
|
||||
less.refresh(less.env === 'development');
|
||||
less.registerStylesheets().then(
|
||||
function () {
|
||||
less.refresh(less.env === 'development');
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user