change default for useFileCache. Fixes #2261

This commit is contained in:
Luke Page
2014-11-01 14:30:29 +00:00
parent 062afacfe0
commit d48fd51661
2 changed files with 12 additions and 7 deletions

View File

@@ -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)) {

View File

@@ -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();