[Pkg-javascript-commits] [less.js] 171/285: Fixes #713, #771, #1161

Jonas Smedegaard dr at jones.dk
Mon Oct 26 23:23:51 UTC 2015


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag v2.0.0
in repository less.js.

commit d31be578a3b35c7b0f43738e26f42576bab48ce9
Author: Levi Thomason <me at levithomason.com>
Date:   Wed Oct 15 22:46:20 2014 -0700

    Fixes #713, #771, #1161
---
 lib/less-browser/index.js | 32 ++++++++++++++++++++++----------
 1 file changed, 22 insertions(+), 10 deletions(-)

diff --git a/lib/less-browser/index.js b/lib/less-browser/index.js
index fcad374..5c69aad 100644
--- a/lib/less-browser/index.js
+++ b/lib/less-browser/index.js
@@ -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.sheets = [];
+less.registerStylesheets = function(callback) {
+    return new PromiseConstructor(function(resolve, reject) {
+        var links = document.getElementsByTagName('link');
+        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');
+    }
+);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/less.js.git



More information about the Pkg-javascript-commits mailing list