[Pkg-javascript-commits] [less.js] 33/38: Some simplification in the browser and do not cache if modify vars is se. Fixes #2054

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


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

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

commit 9e279a69d8dffdfbfc5bddeb1c6d251b79c31a10
Author: Luke Page <luke.a.page at gmail.com>
Date:   Sun Jan 4 08:11:48 2015 +0000

    Some simplification in the browser and do not cache if modify vars is se. Fixes #2054
---
 lib/less-browser/index.js | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/lib/less-browser/index.js b/lib/less-browser/index.js
index f0762be..2f2e8b7 100644
--- a/lib/less-browser/index.js
+++ b/lib/less-browser/index.js
@@ -112,13 +112,14 @@ function loadStyleSheet(sheet, callback, reload, remaining, modifyVars) {
         if (webInfo) {
             webInfo.remaining = remaining;
 
-            var css = cache.getCSS(path, webInfo);
-            if (!reload && css) {
-                browser.createCSS(window.document, css, sheet);
-                webInfo.local = true;
-                callback(null, null, data, sheet, webInfo, path);
-                return;
-            }
+	        if (!instanceOptions.modifyVars) {
+	            var css = cache.getCSS(path, webInfo);
+	            if (!reload && css) {
+	                webInfo.local = true;
+	                callback(null, null, data, sheet, webInfo, path);
+	                return;
+	            }
+	        }
         }
 
         //TODO add tests around how this behaves when reloading
@@ -130,7 +131,11 @@ function loadStyleSheet(sheet, callback, reload, remaining, modifyVars) {
                 e.href = path;
                 callback(e);
             } else {
-                callback(null, result.css, data, sheet, webInfo, path);
+	            result.css = postProcessCSS(result.css);
+	            if (!instanceOptions.modifyVars) {
+	                cache.setCSS(sheet.href, webInfo.lastModified, result.css);
+	            }
+	            callback(null, result.css, data, sheet, webInfo, path);
             }
         });
     }
@@ -155,13 +160,11 @@ function initRunningMode(){
         less.watchTimer = setInterval(function () {
             if (less.watchMode) {
                 fileManager.clearFileCache();
-                loadStyleSheets(function (e, css, _, sheet, context) {
+                loadStyleSheets(function (e, css, _, sheet, webInfo) {
                     if (e) {
                         errors.add(e, e.href || sheet.href);
                     } else if (css) {
-                        css = postProcessCSS(css);
                         browser.createCSS(window.document, css, sheet);
-                        cache.setCSS(sheet.href, context.lastModified, css);
                     }
                 });
             }
@@ -228,10 +231,8 @@ less.refresh = function (reload, modifyVars, clearFileCache) {
                 less.logger.info("loading " + sheet.href + " from cache.");
             } else {
                 less.logger.info("rendered " + sheet.href + " successfully.");
-                css = postProcessCSS(css);
-                browser.createCSS(window.document, css, sheet);
-                cache.setCSS(sheet.href, webInfo.lastModified, css);
             }
+	        browser.createCSS(window.document, css, sheet);
             less.logger.info("css for " + sheet.href + " generated in " + (new Date() - endTime) + 'ms');
             if (webInfo.remaining === 0) {
                 totalMilliseconds = new Date() - startTime;

-- 
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