[Pkg-javascript-commits] [less.js] 248/285: change default for useFileCache. Fixes #2261

Jonas Smedegaard dr at jones.dk
Mon Oct 26 23:23:59 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 d48fd5166184bb3f70b9e9eb392b83abd5fd1797
Author: Luke Page <luke.a.page at gmail.com>
Date:   Sat Nov 1 14:30:29 2014 +0000

    change default for useFileCache. Fixes #2261
---
 lib/less-browser/file-manager.js |  4 ++++
 lib/less-browser/index.js        | 15 ++++++++-------
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/lib/less-browser/file-manager.js b/lib/less-browser/file-manager.js
index cf1cc50..680c45b 100644
--- a/lib/less-browser/file-manager.js
+++ b/lib/less-browser/file-manager.js
@@ -80,6 +80,10 @@ FileManager.prototype.supports = function(filename, currentDirectory, options, e
     return true;
 };
 
+FileManager.prototype.clearFileCache = function() {
+    fileCache = {};
+};
+
 FileManager.prototype.loadFile = function loadFile(filename, currentDirectory, options, environment) {
     return new PromiseConstructor(function(fullfill, reject) {
         if (currentDirectory && !this.isPathAbsolute(filename)) {
diff --git a/lib/less-browser/index.js b/lib/less-browser/index.js
index 0f38709..ea32ee0 100644
--- a/lib/less-browser/index.js
+++ b/lib/less-browser/index.js
@@ -68,6 +68,10 @@ if (dumpLineNumbers) {
     options.dumpLineNumbers = dumpLineNumbers[1];
 }
 
+if (options.useFileCache === undefined) {
+    options.useFileCache = true;
+}
+
 var typePattern = /^text\/(x-)?less$/;
 
 function postProcessCSS(styles) {
@@ -108,10 +112,6 @@ function loadStyles(modifyVars) {
             var lessText = style.innerHTML || '';
             instanceOptions.filename = document.location.href.replace(/#.*$/, '');
 
-            if (modifyVars || instanceOptions.globalVars) {
-                instanceOptions.useFileCache = true;
-            }
-
             /*jshint loopfunc:true */
             // use closure to store current style
             less.render(lessText, instanceOptions)
@@ -138,9 +138,6 @@ function loadStyleSheet(sheet, callback, reload, remaining, modifyVars) {
     if (modifyVars) {
         instanceOptions.modifyVars = modifyVars;
     }
-    if (modifyVars || options.globalVars) {
-        instanceOptions.useFileCache = true;
-    }
 
     fileManager.loadFile(sheet.href, null, instanceOptions, environment)
     .then(function loadInitialFileCallback(loadedFile) {
@@ -198,6 +195,7 @@ function initRunningMode(){
     if (less.env === 'development') {
         less.watchTimer = setInterval(function () {
             if (less.watchMode) {
+                fileManager.clearFileCache();
                 loadStyleSheets(function (e, css, _, sheet, context) {
                     if (e) {
                         errors.add(e, e.href || sheet.href);
@@ -258,6 +256,9 @@ less.modifyVars = function(record) {
 };
 
 less.refresh = function (reload, modifyVars) {
+    if (reload) {
+        fileManager.clearFileCache();
+    }
     return new Promise(function (resolve, reject) {
         var startTime, endTime, totalMilliseconds;
         startTime = endTime = new Date();

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