// Browsers have good Promise support
-require("promise/polyfill");
+require('promise/polyfill');
var options = require('../less/default-options')();
@@ -82,7 +83,7 @@ if (window.less) {
}
}
}
-require("./add-default-options")(window, options);
+require('./add-default-options')(window, options);
options.plugins = options.plugins || [];
@@ -90,7 +91,7 @@ if (window.LESS_PLUGINS) {
options.plugins = options.plugins.concat(window.LESS_PLUGINS);
}
-var less = module.exports = require("./index")(window, options);
+var less = module.exports = require('./index')(window, options);
window.less = less;
@@ -129,8 +130,8 @@ if (options.onReady) {
less.pageLoadFinished = less.refresh(less.env === 'development').then(resolveOrReject, resolveOrReject);
}
-},{"../less/default-options":16,"./add-default-options":1,"./index":8,"promise/polyfill":100}],3:[function(require,module,exports){
-var utils = require("./utils");
+},{"../less/default-options":16,"./add-default-options":1,"./index":8,"promise/polyfill":101}],3:[function(require,module,exports){
+var utils = require('./utils');
module.exports = {
createCSS: function (document, styles, sheet) {
// Strip the query-string
@@ -182,14 +183,14 @@ module.exports = {
try {
styleNode.styleSheet.cssText = styles;
} catch (e) {
- throw new Error("Couldn't reassign styleSheet.cssText.");
+ throw new Error('Couldn\'t reassign styleSheet.cssText.');
}
}
},
currentScript: function(window) {
var document = window.document;
return document.currentScript || (function() {
- var scripts = document.getElementsByTagName("script");
+ var scripts = document.getElementsByTagName('script');
return scripts[scripts.length - 1];
})();
}
@@ -227,11 +228,12 @@ module.exports = function(window, options, logger) {
vars = cache && cache.getItem(path + ':vars');
modifyVars = modifyVars || {};
+ vars = vars || "{}"; // if not set, treat as the JSON representation of an empty object
if (timestamp && webInfo.lastModified &&
(new Date(webInfo.lastModified).valueOf() ===
new Date(timestamp).valueOf()) &&
- (!modifyVars && !vars || JSON.stringify(modifyVars) === vars)) {
+ JSON.stringify(modifyVars) === vars) {
// Use local copy
return css;
}
@@ -240,23 +242,23 @@ module.exports = function(window, options, logger) {
};
},{}],5:[function(require,module,exports){
-var utils = require("./utils"),
- browser = require("./browser");
+var utils = require('./utils'),
+ browser = require('./browser');
module.exports = function(window, less, options) {
function errorHTML(e, rootHref) {
- var id = 'less-error-message:' + utils.extractId(rootHref || "");
+ var id = 'less-error-message:' + utils.extractId(rootHref || '');
var template = '{content}';
var elem = window.document.createElement('div'), timer, content, errors = [];
var filename = e.filename || rootHref;
var filenameNoPath = filename.match(/([^\/]+(\?.*)?)$/)[1];
elem.id = id;
- elem.className = "less-error-message";
+ elem.className = 'less-error-message';
- content = '' + (e.type || "Syntax") + "Error: " + (e.message || 'There is an error in your .less file') +
- '
' + 'in ' + filenameNoPath + " ";
+ content = '
' + (e.type || 'Syntax') + 'Error: ' + (e.message || 'There is an error in your .less file') +
+ '
' + 'in ' + filenameNoPath + ' ';
var errorline = function (e, i, classname) {
if (e.extract[i] !== undefined) {
@@ -319,15 +321,15 @@ module.exports = function(window, less, options) {
].join('\n'), { title: 'error-message' });
elem.style.cssText = [
- "font-family: Arial, sans-serif",
- "border: 1px solid #e00",
- "background-color: #eee",
- "border-radius: 5px",
- "-webkit-border-radius: 5px",
- "-moz-border-radius: 5px",
- "color: #e00",
- "padding: 15px",
- "margin-bottom: 15px"
+ 'font-family: Arial, sans-serif',
+ 'border: 1px solid #e00',
+ 'background-color: #eee',
+ 'border-radius: 5px',
+ '-webkit-border-radius: 5px',
+ '-moz-border-radius: 5px',
+ 'color: #e00',
+ 'padding: 15px',
+ 'margin-bottom: 15px'
].join(';');
if (options.env === 'development') {
@@ -358,12 +360,12 @@ module.exports = function(window, less, options) {
}
function removeError(path) {
- if (!options.errorReporting || options.errorReporting === "html") {
+ if (!options.errorReporting || options.errorReporting === 'html') {
removeErrorHTML(path);
- } else if (options.errorReporting === "console") {
+ } else if (options.errorReporting === 'console') {
removeErrorConsole(path);
} else if (typeof options.errorReporting === 'function') {
- options.errorReporting("remove", path);
+ options.errorReporting('remove', path);
}
}
@@ -371,8 +373,8 @@ module.exports = function(window, less, options) {
var template = '{line} {content}';
var filename = e.filename || rootHref;
var errors = [];
- var content = (e.type || "Syntax") + "Error: " + (e.message || 'There is an error in your .less file') +
- " in " + filename;
+ var content = (e.type || 'Syntax') + 'Error: ' + (e.message || 'There is an error in your .less file') +
+ ' in ' + filename;
var errorline = function (e, i, classname) {
if (e.extract[i] !== undefined) {
@@ -396,12 +398,12 @@ module.exports = function(window, less, options) {
}
function error(e, rootHref) {
- if (!options.errorReporting || options.errorReporting === "html") {
+ if (!options.errorReporting || options.errorReporting === 'html') {
errorHTML(e, rootHref);
- } else if (options.errorReporting === "console") {
+ } else if (options.errorReporting === 'console') {
errorConsole(e, rootHref);
} else if (typeof options.errorReporting === 'function') {
- options.errorReporting("add", e, rootHref);
+ options.errorReporting('add', e, rootHref);
}
}
@@ -416,7 +418,7 @@ module.exports = function(window, less, options) {
module.exports = function(options, logger) {
- var AbstractFileManager = require("../less/environment/abstract-file-manager.js");
+ var AbstractFileManager = require('../less/environment/abstract-file-manager.js');
var fileCache = {};
@@ -443,7 +445,7 @@ module.exports = function(options, logger) {
if (typeof xhr.overrideMimeType === 'function') {
xhr.overrideMimeType('text/css');
}
- logger.debug("XHR: Getting '" + url + "'");
+ logger.debug('XHR: Getting \'' + url + '\'');
xhr.open('GET', url, async);
xhr.setRequestHeader('Accept', type || 'text/x-less, text/css; q=0.9, */*; q=0.5');
xhr.send(null);
@@ -451,7 +453,7 @@ module.exports = function(options, logger) {
function handleResponse(xhr, callback, errback) {
if (xhr.status >= 200 && xhr.status < 300) {
callback(xhr.responseText,
- xhr.getResponseHeader("Last-Modified"));
+ xhr.getResponseHeader('Last-Modified'));
} else if (typeof errback === 'function') {
errback(xhr.status, url);
}
@@ -505,7 +507,7 @@ module.exports = function(options, logger) {
var lessText = fileCache[href];
return resolve({ contents: lessText, filename: href, webInfo: { lastModified: new Date() }});
} catch (e) {
- return reject({ filename: href, message: "Error loading file " + href + " error was " + e.message });
+ return reject({ filename: href, message: 'Error loading file ' + href + ' error was ' + e.message });
}
}
@@ -516,7 +518,7 @@ module.exports = function(options, logger) {
// Use remote copy (re-parse)
resolve({ contents: data, filename: href, webInfo: { lastModified: lastModified }});
}, function doXHRError(status, url) {
- reject({ type: 'File', message: "'" + url + "' wasn't found (" + status + ")", href: href });
+ reject({ type: 'File', message: '\'' + url + '\' wasn\'t found (' + status + ')', href: href });
});
});
};
@@ -527,25 +529,25 @@ module.exports = function(options, logger) {
},{"../less/environment/abstract-file-manager.js":17}],7:[function(require,module,exports){
module.exports = function() {
- var functionRegistry = require("./../less/functions/function-registry");
+ var functionRegistry = require('./../less/functions/function-registry');
function imageSize() {
throw {
- type: "Runtime",
- message: "Image size functions are not supported in browser version of less"
+ type: 'Runtime',
+ message: 'Image size functions are not supported in browser version of less'
};
}
var imageFunctions = {
- "image-size": function(filePathNode) {
+ 'image-size': function(filePathNode) {
imageSize(this, filePathNode);
return -1;
},
- "image-width": function(filePathNode) {
+ 'image-width': function(filePathNode) {
imageSize(this, filePathNode);
return -1;
},
- "image-height": function(filePathNode) {
+ 'image-height': function(filePathNode) {
imageSize(this, filePathNode);
return -1;
}
@@ -559,8 +561,8 @@ module.exports = function() {
// index.js
// Should expose the additional browser functions on to the less object
//
-var addDataAttr = require("./utils").addDataAttr,
- browser = require("./browser");
+var addDataAttr = require('./utils').addDataAttr,
+ browser = require('./browser');
module.exports = function(window, options) {
var document = window.document;
@@ -568,15 +570,15 @@ module.exports = function(window, options) {
less.options = options;
var environment = less.environment,
- FileManager = require("./file-manager")(options, less.logger),
+ FileManager = require('./file-manager')(options, less.logger),
fileManager = new FileManager();
environment.addFileManager(fileManager);
less.FileManager = FileManager;
- less.PluginLoader = require("./plugin-loader");
+ less.PluginLoader = require('./plugin-loader');
- require("./log-listener")(less, options);
- var errors = require("./error-reporting")(window, less, options);
- var cache = less.cache = options.cache || require("./cache")(window, options, less.logger);
+ require('./log-listener')(less, options);
+ var errors = require('./error-reporting')(window, less, options);
+ var cache = less.cache = options.cache || require('./cache')(window, options, less.logger);
require('./image-size')(less.environment);
// Setup user functions - Deprecate?
@@ -616,7 +618,7 @@ module.exports = function(window, options) {
less.render(lessText, instanceOptions,
bind(function(style, e, result) {
if (e) {
- errors.add(e, "inline");
+ errors.add(e, 'inline');
} else {
style.type = 'text/css';
if (style.styleSheet) {
@@ -779,7 +781,7 @@ module.exports = function(window, options) {
endTime = new Date();
totalMilliseconds = endTime - startTime;
- less.logger.info("Less has finished and no sheets were loaded.");
+ less.logger.info('Less has finished and no sheets were loaded.');
resolve({
startTime: startTime,
endTime: endTime,
@@ -796,12 +798,12 @@ module.exports = function(window, options) {
return;
}
if (webInfo.local) {
- less.logger.info("Loading " + sheet.href + " from cache.");
+ less.logger.info('Loading ' + sheet.href + ' from cache.');
} else {
- less.logger.info("Rendered " + sheet.href + " successfully.");
+ less.logger.info('Rendered ' + sheet.href + ' successfully.');
}
browser.createCSS(window.document, css, sheet);
- less.logger.info("CSS for " + sheet.href + " generated in " + (new Date() - endTime) + 'ms');
+ less.logger.info('CSS for ' + sheet.href + ' generated in ' + (new Date() - endTime) + 'ms');
// Count completed sheet
remainingSheets--;
@@ -809,7 +811,7 @@ module.exports = function(window, options) {
// Check if the last remaining sheet was processed and then call the promise
if (remainingSheets === 0) {
totalMilliseconds = new Date() - startTime;
- less.logger.info("Less has finished. CSS generated in " + totalMilliseconds + 'ms');
+ less.logger.info('Less has finished. CSS generated in ' + totalMilliseconds + 'ms');
resolve({
startTime: startTime,
endTime: endTime,
@@ -876,17 +878,16 @@ module.exports = function(less, options) {
},{}],10:[function(require,module,exports){
// TODO: Add tests for browser @plugin
-/*global window */
+/* global window */
-var AbstractPluginLoader = require("../less/environment/abstract-plugin-loader.js");
+var AbstractPluginLoader = require('../less/environment/abstract-plugin-loader.js');
/**
* Browser Plugin Loader
*/
var PluginLoader = function(less) {
this.less = less;
- // shim for browser require?
- this.require = require;
+ // Should we shim this.require for browser? Probably not?
};
PluginLoader.prototype = new AbstractPluginLoader();
@@ -914,7 +915,7 @@ module.exports = {
addDataAttr: function(options, tag) {
for (var opt in tag.dataset) {
if (tag.dataset.hasOwnProperty(opt)) {
- if (opt === "env" || opt === "dumpLineNumbers" || opt === "rootpath" || opt === "errorReporting") {
+ if (opt === 'env' || opt === 'dumpLineNumbers' || opt === 'rootpath' || opt === 'errorReporting') {
options[opt] = tag.dataset[opt];
} else {
try {
@@ -966,7 +967,7 @@ var parseCopyProperties = [
contexts.Parse = function(options) {
copyFromOriginal(options, this, parseCopyProperties);
- if (typeof this.paths === "string") { this.paths = [this.paths]; }
+ if (typeof this.paths === 'string') { this.paths = [this.paths]; }
};
var evalCopyProperties = [
@@ -986,12 +987,27 @@ var evalCopyProperties = [
contexts.Eval = function(options, frames) {
copyFromOriginal(options, this, evalCopyProperties);
- if (typeof this.paths === "string") { this.paths = [this.paths]; }
+ if (typeof this.paths === 'string') { this.paths = [this.paths]; }
this.frames = frames || [];
this.importantScope = this.importantScope || [];
};
+contexts.Eval.prototype.enterCalc = function () {
+ if (!this.calcStack) {
+ this.calcStack = [];
+ }
+ this.calcStack.push(true);
+ this.inCalc = true;
+};
+
+contexts.Eval.prototype.exitCalc = function () {
+ this.calcStack.pop();
+ if (!this.calcStack) {
+ this.inCalc = false;
+ }
+};
+
contexts.Eval.prototype.inParenthesis = function () {
if (!this.parensStack) {
this.parensStack = [];
@@ -1003,6 +1019,7 @@ contexts.Eval.prototype.outOfParenthesis = function () {
this.parensStack.pop();
};
+contexts.Eval.prototype.inCalc = false;
contexts.Eval.prototype.mathOn = true;
contexts.Eval.prototype.isMathOn = function () {
if (!this.mathOn) {
@@ -1017,17 +1034,17 @@ contexts.Eval.prototype.isPathRelative = function (path) {
contexts.Eval.prototype.normalizePath = function( path ) {
var
- segments = path.split("/").reverse(),
+ segments = path.split('/').reverse(),
segment;
path = [];
while (segments.length !== 0 ) {
segment = segments.pop();
switch ( segment ) {
- case ".":
+ case '.':
break;
- case "..":
- if ((path.length === 0) || (path[path.length - 1] === "..")) {
+ case '..':
+ if ((path.length === 0) || (path[path.length - 1] === '..')) {
path.push( segment );
} else {
path.pop();
@@ -1039,7 +1056,7 @@ contexts.Eval.prototype.normalizePath = function( path ) {
}
}
- return path.join("/");
+ return path.join('/');
};
// todo - do the same for the toCSS ?
@@ -1197,8 +1214,8 @@ module.exports = {
};
},{}],14:[function(require,module,exports){
module.exports = {
- colors: require("./colors"),
- unitConversions: require("./unit-conversions")
+ colors: require('./colors'),
+ unitConversions: require('./unit-conversions')
};
},{"./colors":13,"./unit-conversions":15}],15:[function(require,module,exports){
@@ -1303,7 +1320,7 @@ abstractFileManager.prototype.getPath = function (filename) {
j = filename.lastIndexOf('\\');
}
if (j < 0) {
- return "";
+ return '';
}
return filename.slice(0, j + 1);
};
@@ -1340,9 +1357,9 @@ abstractFileManager.prototype.pathDiff = function pathDiff(url, baseUrl) {
var urlParts = this.extractUrlParts(url),
baseUrlParts = this.extractUrlParts(baseUrl),
- i, max, urlDirectories, baseUrlDirectories, diff = "";
+ i, max, urlDirectories, baseUrlDirectories, diff = '';
if (urlParts.hostPart !== baseUrlParts.hostPart) {
- return "";
+ return '';
}
max = Math.max(baseUrlParts.directories.length, urlParts.directories.length);
for (i = 0; i < max; i++) {
@@ -1351,10 +1368,10 @@ abstractFileManager.prototype.pathDiff = function pathDiff(url, baseUrl) {
baseUrlDirectories = baseUrlParts.directories.slice(i);
urlDirectories = urlParts.directories.slice(i);
for (i = 0; i < baseUrlDirectories.length - 1; i++) {
- diff += "../";
+ diff += '../';
}
for (i = 0; i < urlDirectories.length - 1; i++) {
- diff += urlDirectories[i] + "/";
+ diff += urlDirectories[i] + '/';
}
return diff;
};
@@ -1371,31 +1388,31 @@ abstractFileManager.prototype.extractUrlParts = function extractUrlParts(url, ba
returner = {}, rawDirectories = [], directories = [], i, baseUrlParts;
if (!urlParts) {
- throw new Error("Could not parse sheet href - '" + url + "'");
+ throw new Error('Could not parse sheet href - \'' + url + '\'');
}
// Stylesheets in IE don't always return the full path
if (baseUrl && (!urlParts[1] || urlParts[2])) {
baseUrlParts = baseUrl.match(urlPartsRegex);
if (!baseUrlParts) {
- throw new Error("Could not parse page url - '" + baseUrl + "'");
+ throw new Error('Could not parse page url - \'' + baseUrl + '\'');
}
- urlParts[1] = urlParts[1] || baseUrlParts[1] || "";
+ urlParts[1] = urlParts[1] || baseUrlParts[1] || '';
if (!urlParts[2]) {
urlParts[3] = baseUrlParts[3] + urlParts[3];
}
}
if (urlParts[3]) {
- rawDirectories = urlParts[3].replace(/\\/g, "/").split("/");
+ rawDirectories = urlParts[3].replace(/\\/g, '/').split('/');
// collapse '..' and skip '.'
for (i = 0; i < rawDirectories.length; i++) {
- if (rawDirectories[i] === "..") {
+ if (rawDirectories[i] === '..') {
directories.pop();
}
- else if (rawDirectories[i] !== ".") {
+ else if (rawDirectories[i] !== '.') {
directories.push(rawDirectories[i]);
}
@@ -1404,31 +1421,27 @@ abstractFileManager.prototype.extractUrlParts = function extractUrlParts(url, ba
returner.hostPart = urlParts[1];
returner.directories = directories;
- returner.rawPath = (urlParts[1] || "") + rawDirectories.join("/");
- returner.path = (urlParts[1] || "") + directories.join("/");
+ returner.rawPath = (urlParts[1] || '') + rawDirectories.join('/');
+ returner.path = (urlParts[1] || '') + directories.join('/');
returner.filename = urlParts[4];
- returner.fileUrl = returner.path + (urlParts[4] || "");
- returner.url = returner.fileUrl + (urlParts[5] || "");
+ returner.fileUrl = returner.path + (urlParts[4] || '');
+ returner.url = returner.fileUrl + (urlParts[5] || '');
return returner;
};
module.exports = abstractFileManager;
},{}],18:[function(require,module,exports){
-var functionRegistry = require("../functions/function-registry"),
+var functionRegistry = require('../functions/function-registry'),
LessError = require('../less-error');
var AbstractPluginLoader = function() {
+ // Implemented by Node.js plugin loader
+ this.require = function() {
+ return null;
+ }
};
-function error(msg, type) {
- throw new LessError(
- {
- type: type || 'Syntax',
- message: msg
- }
- );
-}
AbstractPluginLoader.prototype.evalPlugin = function(contents, context, imports, pluginOptions, fileInfo) {
var loader,
@@ -1436,12 +1449,13 @@ AbstractPluginLoader.prototype.evalPlugin = function(contents, context, imports,
pluginObj,
localModule,
pluginManager,
- filename;
+ filename,
+ result;
pluginManager = context.pluginManager;
if (fileInfo) {
- if (typeof fileInfo === "string") {
+ if (typeof fileInfo === 'string') {
filename = fileInfo;
}
else {
@@ -1454,15 +1468,18 @@ AbstractPluginLoader.prototype.evalPlugin = function(contents, context, imports,
pluginObj = pluginManager.get(filename);
if (pluginObj) {
- this.trySetOptions(pluginObj, filename, shortname, pluginOptions);
+ result = this.trySetOptions(pluginObj, filename, shortname, pluginOptions);
+ if (result) {
+ return result;
+ }
try {
if (pluginObj.use) {
pluginObj.use.call(this.context, pluginObj);
}
}
catch (e) {
- e.message = 'Error during @plugin call';
- return new this.less.LessError(e, imports, filename);
+ e.message = e.message || 'Error during @plugin call';
+ return new LessError(e, imports, filename);
}
return pluginObj;
}
@@ -1479,10 +1496,11 @@ AbstractPluginLoader.prototype.evalPlugin = function(contents, context, imports,
};
try {
- loader = new Function("module", "require", "registerPlugin", "functions", "tree", "less", "fileInfo", contents);
- loader(localModule, this.require, registerPlugin, registry, this.less.tree, this.less, fileInfo);
- } catch (e) {
- return new this.less.LessError(e, imports, filename);
+ loader = new Function('module', 'require', 'registerPlugin', 'functions', 'tree', 'less', 'fileInfo', contents);
+ loader(localModule, this.require(filename), registerPlugin, registry, this.less.tree, this.less, fileInfo);
+ }
+ catch (e) {
+ return new LessError(e, imports, filename);
}
if (!pluginObj) {
@@ -1490,14 +1508,32 @@ AbstractPluginLoader.prototype.evalPlugin = function(contents, context, imports,
}
pluginObj = this.validatePlugin(pluginObj, filename, shortname);
+ if (pluginObj instanceof LessError) {
+ return pluginObj;
+ }
+
if (pluginObj) {
- // Run on first load
- pluginManager.addPlugin(pluginObj, fileInfo.filename, registry);
- pluginObj.functions = registry.getLocalFunctions();
pluginObj.imports = imports;
pluginObj.filename = filename;
- this.trySetOptions(pluginObj, filename, shortname, pluginOptions);
+ // For < 3.x (or unspecified minVersion) - setOptions() before install()
+ if (!pluginObj.minVersion || this.compareVersion('3.0.0', pluginObj.minVersion) < 0) {
+ result = this.trySetOptions(pluginObj, filename, shortname, pluginOptions);
+
+ if (result) {
+ return result;
+ }
+ }
+
+ // Run on first load
+ pluginManager.addPlugin(pluginObj, fileInfo.filename, registry);
+ pluginObj.functions = registry.getLocalFunctions();
+
+ // Need to call setOptions again because the pluginObj might have functions
+ result = this.trySetOptions(pluginObj, filename, shortname, pluginOptions);
+ if (result) {
+ return result;
+ }
// Run every @plugin call
try {
@@ -1506,13 +1542,13 @@ AbstractPluginLoader.prototype.evalPlugin = function(contents, context, imports,
}
}
catch (e) {
- e.message = 'Error during @plugin call';
- return new this.less.LessError(e, imports, filename);
+ e.message = e.message || 'Error during @plugin call';
+ return new LessError(e, imports, filename);
}
}
else {
- return new this.less.LessError({ message: "Not a valid plugin" });
+ return new LessError({ message: 'Not a valid plugin' }, imports, filename);
}
return pluginObj;
@@ -1520,18 +1556,17 @@ AbstractPluginLoader.prototype.evalPlugin = function(contents, context, imports,
};
AbstractPluginLoader.prototype.trySetOptions = function(plugin, filename, name, options) {
- if (options) {
- if (!plugin.setOptions) {
- error("Options have been provided but the plugin " + name + " does not support any options.");
- return null;
- }
- try {
- plugin.setOptions(options);
- }
- catch (e) {
- error("Error setting options on plugin " + name + '\n' + e.message);
- return null;
- }
+ if (options && !plugin.setOptions) {
+ return new LessError({
+ message: 'Options have been provided but the plugin ' +
+ name + ' does not support any options.'
+ });
+ }
+ try {
+ plugin.setOptions && plugin.setOptions(options);
+ }
+ catch (e) {
+ return new LessError(e);
}
};
@@ -1539,14 +1574,16 @@ AbstractPluginLoader.prototype.validatePlugin = function(plugin, filename, name)
if (plugin) {
// support plugins being a function
// so that the plugin can be more usable programmatically
- if (typeof plugin === "function") {
+ if (typeof plugin === 'function') {
plugin = new plugin();
}
if (plugin.minVersion) {
if (this.compareVersion(plugin.minVersion, this.less.version) < 0) {
- error("Plugin " + name + " requires version " + this.versionToString(plugin.minVersion));
- return null;
+ return new LessError({
+ message: 'Plugin ' + name + ' requires version ' +
+ this.versionToString(plugin.minVersion)
+ });
}
}
return plugin;
@@ -1555,7 +1592,7 @@ AbstractPluginLoader.prototype.validatePlugin = function(plugin, filename, name)
};
AbstractPluginLoader.prototype.compareVersion = function(aVersion, bVersion) {
- if (typeof aVersion === "string") {
+ if (typeof aVersion === 'string') {
aVersion = aVersion.match(/^(\d+)\.?(\d+)?\.?(\d+)?/);
aVersion.shift();
}
@@ -1567,9 +1604,9 @@ AbstractPluginLoader.prototype.compareVersion = function(aVersion, bVersion) {
return 0;
};
AbstractPluginLoader.prototype.versionToString = function(version) {
- var versionString = "";
+ var versionString = '';
for (var i = 0; i < version.length; i++) {
- versionString += (versionString ? "." : "") + version[i];
+ versionString += (versionString ? '.' : '') + version[i];
}
return versionString;
};
@@ -1591,12 +1628,12 @@ module.exports = AbstractPluginLoader;
* environment, file managers, and plugin manager
*/
-var logger = require("../logger");
+var logger = require('../logger');
var environment = function(externalEnvironment, fileManagers) {
this.fileManagers = fileManagers || [];
externalEnvironment = externalEnvironment || {};
- var optionalFunctions = ["encodeBase64", "mimeLookup", "charsetLookup", "getSourceMapGenerator"],
+ var optionalFunctions = ['encodeBase64', 'mimeLookup', 'charsetLookup', 'getSourceMapGenerator'],
requiredFunctions = [],
functions = requiredFunctions.concat(optionalFunctions);
@@ -1606,7 +1643,7 @@ var environment = function(externalEnvironment, fileManagers) {
if (environmentFunc) {
this[propName] = environmentFunc.bind(externalEnvironment);
} else if (i < requiredFunctions.length) {
- this.warn("missing required function in environment - " + propName);
+ this.warn('missing required function in environment - ' + propName);
}
}
};
@@ -1614,10 +1651,10 @@ var environment = function(externalEnvironment, fileManagers) {
environment.prototype.getFileManager = function (filename, currentDirectory, options, environment, isSync) {
if (!filename) {
- logger.warn("getFileManager called with no filename.. Please report this issue. continuing.");
+ logger.warn('getFileManager called with no filename.. Please report this issue. continuing.');
}
if (currentDirectory == null) {
- logger.warn("getFileManager called with null directory.. Please report this issue. continuing.");
+ logger.warn('getFileManager called with null directory.. Please report this issue. continuing.');
}
var fileManagers = this.fileManagers;
@@ -1626,7 +1663,7 @@ environment.prototype.getFileManager = function (filename, currentDirectory, opt
}
for (var i = fileManagers.length - 1; i >= 0 ; i--) {
var fileManager = fileManagers[i];
- if (fileManager[isSync ? "supportsSync" : "supports"](filename, currentDirectory, options, environment)) {
+ if (fileManager[isSync ? 'supportsSync' : 'supports'](filename, currentDirectory, options, environment)) {
return fileManager;
}
}
@@ -1645,9 +1682,9 @@ module.exports = environment;
},{"../logger":37}],20:[function(require,module,exports){
-var functionRegistry = require("./function-registry"),
- Anonymous = require("../tree/anonymous"),
- Keyword = require("../tree/keyword");
+var functionRegistry = require('./function-registry'),
+ Anonymous = require('../tree/anonymous'),
+ Keyword = require('../tree/keyword');
functionRegistry.addMultiple({
boolean: function(condition) {
@@ -1661,8 +1698,8 @@ functionRegistry.addMultiple({
});
},{"../tree/anonymous":48,"../tree/keyword":68,"./function-registry":26}],21:[function(require,module,exports){
-var Color = require("../tree/color"),
- functionRegistry = require("./function-registry");
+var Color = require('../tree/color'),
+ functionRegistry = require('./function-registry');
// Color Blending
// ref: http://www.w3.org/TR/compositing-1
@@ -1737,11 +1774,11 @@ for (var f in colorBlendModeFunctions) {
functionRegistry.addMultiple(colorBlend);
},{"../tree/color":53,"./function-registry":26}],22:[function(require,module,exports){
-var Dimension = require("../tree/dimension"),
- Color = require("../tree/color"),
- Quoted = require("../tree/quoted"),
- Anonymous = require("../tree/anonymous"),
- functionRegistry = require("./function-registry"),
+var Dimension = require('../tree/dimension'),
+ Color = require('../tree/color'),
+ Quoted = require('../tree/quoted'),
+ Anonymous = require('../tree/anonymous'),
+ functionRegistry = require('./function-registry'),
colorFunctions;
function clamp(val) {
@@ -1757,8 +1794,8 @@ function number(n) {
return n;
} else {
throw {
- type: "Argument",
- message: "color functions take numbers as parameters"
+ type: 'Argument',
+ message: 'color functions take numbers as parameters'
};
}
}
@@ -1891,7 +1928,7 @@ colorFunctions = {
}
var hsl = color.toHSL();
- if (typeof method !== "undefined" && method.value === "relative") {
+ if (typeof method !== 'undefined' && method.value === 'relative') {
hsl.s += hsl.s * amount.value / 100;
}
else {
@@ -1903,7 +1940,7 @@ colorFunctions = {
desaturate: function (color, amount, method) {
var hsl = color.toHSL();
- if (typeof method !== "undefined" && method.value === "relative") {
+ if (typeof method !== 'undefined' && method.value === 'relative') {
hsl.s -= hsl.s * amount.value / 100;
}
else {
@@ -1915,7 +1952,7 @@ colorFunctions = {
lighten: function (color, amount, method) {
var hsl = color.toHSL();
- if (typeof method !== "undefined" && method.value === "relative") {
+ if (typeof method !== 'undefined' && method.value === 'relative') {
hsl.l += hsl.l * amount.value / 100;
}
else {
@@ -1927,7 +1964,7 @@ colorFunctions = {
darken: function (color, amount, method) {
var hsl = color.toHSL();
- if (typeof method !== "undefined" && method.value === "relative") {
+ if (typeof method !== 'undefined' && method.value === 'relative') {
hsl.l -= hsl.l * amount.value / 100;
}
else {
@@ -1939,7 +1976,7 @@ colorFunctions = {
fadein: function (color, amount, method) {
var hsl = color.toHSL();
- if (typeof method !== "undefined" && method.value === "relative") {
+ if (typeof method !== 'undefined' && method.value === 'relative') {
hsl.a += hsl.a * amount.value / 100;
}
else {
@@ -1951,7 +1988,7 @@ colorFunctions = {
fadeout: function (color, amount, method) {
var hsl = color.toHSL();
- if (typeof method !== "undefined" && method.value === "relative") {
+ if (typeof method !== 'undefined' && method.value === 'relative') {
hsl.a -= hsl.a * amount.value / 100;
}
else {
@@ -2085,8 +2122,8 @@ colorFunctions = {
return c;
}
throw {
- type: "Argument",
- message: "argument must be a color keyword or 3/6 digit hex e.g. #FFF"
+ type: 'Argument',
+ message: 'argument must be a color keyword or 3/6 digit hex e.g. #FFF'
};
},
tint: function(color, amount) {
@@ -2098,18 +2135,18 @@ colorFunctions = {
};
functionRegistry.addMultiple(colorFunctions);
-},{"../tree/anonymous":48,"../tree/color":53,"../tree/dimension":60,"../tree/quoted":77,"./function-registry":26}],23:[function(require,module,exports){
+},{"../tree/anonymous":48,"../tree/color":53,"../tree/dimension":60,"../tree/quoted":78,"./function-registry":26}],23:[function(require,module,exports){
module.exports = function(environment) {
- var Quoted = require("../tree/quoted"),
- URL = require("../tree/url"),
+ var Quoted = require('../tree/quoted'),
+ URL = require('../tree/url'),
utils = require('../utils'),
- functionRegistry = require("./function-registry"),
+ functionRegistry = require('./function-registry'),
fallback = function(functionThis, node) {
return new URL(node, functionThis.index, functionThis.currentFileInfo).eval(functionThis.context);
},
logger = require('../logger');
- functionRegistry.add("data-uri", function(mimetypeNode, filePathNode) {
+ functionRegistry.add('data-uri', function(mimetypeNode, filePathNode) {
if (!filePathNode) {
filePathNode = mimetypeNode;
@@ -2144,7 +2181,7 @@ module.exports = function(environment) {
mimetype = environment.mimeLookup(filePath);
- if (mimetype === "image/svg+xml") {
+ if (mimetype === 'image/svg+xml') {
useBase64 = false;
} else {
// use base 64 unless it's an ASCII or UTF-8 format
@@ -2159,7 +2196,7 @@ module.exports = function(environment) {
var fileSync = fileManager.loadFileSync(filePath, currentDirectory, context, environment);
if (!fileSync.contents) {
- logger.warn("Skipped data-uri embedding of " + filePath + " because file not found");
+ logger.warn('Skipped data-uri embedding of ' + filePath + ' because file not found');
return fallback(this, filePathNode || mimetypeNode);
}
var buf = fileSync.contents;
@@ -2169,7 +2206,7 @@ module.exports = function(environment) {
buf = useBase64 ? environment.encodeBase64(buf) : encodeURIComponent(buf);
- var uri = "data:" + mimetype + ',' + buf + fragment;
+ var uri = 'data:' + mimetype + ',' + buf + fragment;
// IE8 cannot handle a data-uri larger than 32,768 characters. If this is exceeded
// and the --ieCompat flag is enabled, return a normal url() instead.
@@ -2177,8 +2214,8 @@ module.exports = function(environment) {
if (uri.length >= DATA_URI_MAX) {
if (this.context.ieCompat !== false) {
- logger.warn("Skipped data-uri embedding of " + filePath + " because its size (" + uri.length +
- " characters) exceeds IE8-safe " + DATA_URI_MAX + " characters!");
+ logger.warn('Skipped data-uri embedding of ' + filePath + ' because its size (' + uri.length +
+ ' characters) exceeds IE8-safe ' + DATA_URI_MAX + ' characters!');
return fallback(this, filePathNode || mimetypeNode);
}
@@ -2188,9 +2225,9 @@ module.exports = function(environment) {
});
};
-},{"../logger":37,"../tree/quoted":77,"../tree/url":82,"../utils":86,"./function-registry":26}],24:[function(require,module,exports){
-var Keyword = require("../tree/keyword"),
- functionRegistry = require("./function-registry");
+},{"../logger":37,"../tree/quoted":78,"../tree/url":83,"../utils":87,"./function-registry":26}],24:[function(require,module,exports){
+var Keyword = require('../tree/keyword'),
+ functionRegistry = require('./function-registry');
var defaultFunc = {
eval: function () {
@@ -2213,12 +2250,12 @@ var defaultFunc = {
}
};
-functionRegistry.add("default", defaultFunc.eval.bind(defaultFunc));
+functionRegistry.add('default', defaultFunc.eval.bind(defaultFunc));
module.exports = defaultFunc;
},{"../tree/keyword":68,"./function-registry":26}],25:[function(require,module,exports){
-var Expression = require("../tree/expression");
+var Expression = require('../tree/expression');
var functionCaller = function(name, context, index, currentFileInfo) {
this.name = name.toLowerCase();
@@ -2237,15 +2274,15 @@ functionCaller.prototype.call = function(args) {
// https://github.com/less/less.js/issues/2477
if (Array.isArray(args)) {
args = args.filter(function (item) {
- if (item.type === "Comment") {
+ if (item.type === 'Comment') {
return false;
}
return true;
})
.map(function(item) {
- if (item.type === "Expression") {
+ if (item.type === 'Expression') {
var subNodes = item.value.filter(function (item) {
- if (item.type === "Comment") {
+ if (item.type === 'Comment') {
return false;
}
return true;
@@ -2304,33 +2341,33 @@ module.exports = makeRegistry( null );
},{}],27:[function(require,module,exports){
module.exports = function(environment) {
var functions = {
- functionRegistry: require("./function-registry"),
- functionCaller: require("./function-caller")
+ functionRegistry: require('./function-registry'),
+ functionCaller: require('./function-caller')
};
// register functions
- require("./boolean");
- require("./default");
- require("./color");
- require("./color-blending");
- require("./data-uri")(environment);
- require("./math");
- require("./number");
- require("./string");
- require("./svg")(environment);
- require("./types");
+ require('./boolean');
+ require('./default');
+ require('./color');
+ require('./color-blending');
+ require('./data-uri')(environment);
+ require('./math');
+ require('./number');
+ require('./string');
+ require('./svg')(environment);
+ require('./types');
return functions;
};
},{"./boolean":20,"./color":22,"./color-blending":21,"./data-uri":23,"./default":24,"./function-caller":25,"./function-registry":26,"./math":29,"./number":30,"./string":31,"./svg":32,"./types":33}],28:[function(require,module,exports){
-var Dimension = require("../tree/dimension");
+var Dimension = require('../tree/dimension');
var MathHelper = function() {
};
MathHelper._math = function (fn, unit, n) {
if (!(n instanceof Dimension)) {
- throw { type: "Argument", message: "argument must be a number" };
+ throw { type: 'Argument', message: 'argument must be a number' };
}
if (unit == null) {
unit = n.unit;
@@ -2341,8 +2378,8 @@ MathHelper._math = function (fn, unit, n) {
};
module.exports = MathHelper;
},{"../tree/dimension":60}],29:[function(require,module,exports){
-var functionRegistry = require("./function-registry"),
- mathHelper = require("./math-helper.js");
+var functionRegistry = require('./function-registry'),
+ mathHelper = require('./math-helper.js');
var mathFunctions = {
// name, unit
@@ -2350,12 +2387,12 @@ var mathFunctions = {
floor: null,
sqrt: null,
abs: null,
- tan: "",
- sin: "",
- cos: "",
- atan: "rad",
- asin: "rad",
- acos: "rad"
+ tan: '',
+ sin: '',
+ cos: '',
+ atan: 'rad',
+ asin: 'rad',
+ acos: 'rad'
};
for (var f in mathFunctions) {
@@ -2365,22 +2402,22 @@ for (var f in mathFunctions) {
}
mathFunctions.round = function (n, f) {
- var fraction = typeof f === "undefined" ? 0 : f.value;
+ var fraction = typeof f === 'undefined' ? 0 : f.value;
return mathHelper._math(function(num) { return num.toFixed(fraction); }, null, n);
};
functionRegistry.addMultiple(mathFunctions);
},{"./function-registry":26,"./math-helper.js":28}],30:[function(require,module,exports){
-var Dimension = require("../tree/dimension"),
- Anonymous = require("../tree/anonymous"),
- functionRegistry = require("./function-registry"),
- mathHelper = require("./math-helper.js");
+var Dimension = require('../tree/dimension'),
+ Anonymous = require('../tree/anonymous'),
+ functionRegistry = require('./function-registry'),
+ mathHelper = require('./math-helper.js');
var minMax = function (isMin, args) {
args = Array.prototype.slice.call(args);
switch (args.length) {
- case 0: throw { type: "Argument", message: "one or more arguments required" };
+ case 0: throw { type: 'Argument', message: 'one or more arguments required' };
}
var i, j, current, currentUnified, referenceUnified, unit, unitStatic, unitClone,
order = [], // elems only contains original argument values.
@@ -2394,20 +2431,20 @@ var minMax = function (isMin, args) {
}
continue;
}
- currentUnified = current.unit.toString() === "" && unitClone !== undefined ? new Dimension(current.value, unitClone).unify() : current.unify();
- unit = currentUnified.unit.toString() === "" && unitStatic !== undefined ? unitStatic : currentUnified.unit.toString();
- unitStatic = unit !== "" && unitStatic === undefined || unit !== "" && order[0].unify().unit.toString() === "" ? unit : unitStatic;
- unitClone = unit !== "" && unitClone === undefined ? current.unit.toString() : unitClone;
- j = values[""] !== undefined && unit !== "" && unit === unitStatic ? values[""] : values[unit];
+ currentUnified = current.unit.toString() === '' && unitClone !== undefined ? new Dimension(current.value, unitClone).unify() : current.unify();
+ unit = currentUnified.unit.toString() === '' && unitStatic !== undefined ? unitStatic : currentUnified.unit.toString();
+ unitStatic = unit !== '' && unitStatic === undefined || unit !== '' && order[0].unify().unit.toString() === '' ? unit : unitStatic;
+ unitClone = unit !== '' && unitClone === undefined ? current.unit.toString() : unitClone;
+ j = values[''] !== undefined && unit !== '' && unit === unitStatic ? values[''] : values[unit];
if (j === undefined) {
if (unitStatic !== undefined && unit !== unitStatic) {
- throw { type: "Argument", message: "incompatible types" };
+ throw { type: 'Argument', message: 'incompatible types' };
}
values[unit] = order.length;
order.push(current);
continue;
}
- referenceUnified = order[j].unit.toString() === "" && unitClone !== undefined ? new Dimension(order[j].value, unitClone).unify() : order[j].unify();
+ referenceUnified = order[j].unit.toString() === '' && unitClone !== undefined ? new Dimension(order[j].value, unitClone).unify() : order[j].unify();
if ( isMin && currentUnified.value < referenceUnified.value ||
!isMin && currentUnified.value > referenceUnified.value) {
order[j] = current;
@@ -2416,8 +2453,8 @@ var minMax = function (isMin, args) {
if (order.length == 1) {
return order[0];
}
- args = order.map(function (a) { return a.toCSS(this.context); }).join(this.context.compress ? "," : ", ");
- return new Anonymous((isMin ? "min" : "max") + "(" + args + ")");
+ args = order.map(function (a) { return a.toCSS(this.context); }).join(this.context.compress ? ',' : ', ');
+ return new Anonymous((isMin ? 'min' : 'max') + '(' + args + ')');
};
functionRegistry.addMultiple({
min: function () {
@@ -2436,11 +2473,11 @@ functionRegistry.addMultiple({
return new Dimension(a.value % b.value, a.unit);
},
pow: function(x, y) {
- if (typeof x === "number" && typeof y === "number") {
+ if (typeof x === 'number' && typeof y === 'number') {
x = new Dimension(x);
y = new Dimension(y);
} else if (!(x instanceof Dimension) || !(y instanceof Dimension)) {
- throw { type: "Argument", message: "arguments must be numbers" };
+ throw { type: 'Argument', message: 'arguments must be numbers' };
}
return new Dimension(Math.pow(x.value, y.value), x.unit);
@@ -2455,10 +2492,10 @@ functionRegistry.addMultiple({
});
},{"../tree/anonymous":48,"../tree/dimension":60,"./function-registry":26,"./math-helper.js":28}],31:[function(require,module,exports){
-var Quoted = require("../tree/quoted"),
- Anonymous = require("../tree/anonymous"),
- JavaScript = require("../tree/javascript"),
- functionRegistry = require("./function-registry");
+var Quoted = require('../tree/quoted'),
+ Anonymous = require('../tree/anonymous'),
+ JavaScript = require('../tree/javascript'),
+ functionRegistry = require('./function-registry');
functionRegistry.addMultiple({
e: function (str) {
@@ -2466,12 +2503,12 @@ functionRegistry.addMultiple({
},
escape: function (str) {
return new Anonymous(
- encodeURI(str.value).replace(/=/g, "%3D").replace(/:/g, "%3A").replace(/#/g, "%23").replace(/;/g, "%3B")
- .replace(/\(/g, "%28").replace(/\)/g, "%29"));
+ encodeURI(str.value).replace(/=/g, '%3D').replace(/:/g, '%3A').replace(/#/g, '%23').replace(/;/g, '%3B')
+ .replace(/\(/g, '%28').replace(/\)/g, '%29'));
},
replace: function (string, pattern, replacement, flags) {
var result = string.value;
- replacement = (replacement.type === "Quoted") ?
+ replacement = (replacement.type === 'Quoted') ?
replacement.value : replacement.toCSS();
result = result.replace(new RegExp(pattern.value, flags ? flags.value : ''), replacement);
return new Quoted(string.quote || '', result, string.escaped);
@@ -2483,7 +2520,7 @@ functionRegistry.addMultiple({
for (var i = 0; i < args.length; i++) {
/* jshint loopfunc:true */
result = result.replace(/%[sda]/i, function(token) {
- var value = ((args[i].type === "Quoted") &&
+ var value = ((args[i].type === 'Quoted') &&
token.match(/s/i)) ? args[i].value : args[i].toCSS();
return token.match(/[A-Z]$/) ? encodeURIComponent(value) : value;
});
@@ -2493,20 +2530,20 @@ functionRegistry.addMultiple({
}
});
-},{"../tree/anonymous":48,"../tree/javascript":66,"../tree/quoted":77,"./function-registry":26}],32:[function(require,module,exports){
+},{"../tree/anonymous":48,"../tree/javascript":66,"../tree/quoted":78,"./function-registry":26}],32:[function(require,module,exports){
module.exports = function(environment) {
- var Dimension = require("../tree/dimension"),
- Color = require("../tree/color"),
- Expression = require("../tree/expression"),
- Quoted = require("../tree/quoted"),
- URL = require("../tree/url"),
- functionRegistry = require("./function-registry");
+ var Dimension = require('../tree/dimension'),
+ Color = require('../tree/color'),
+ Expression = require('../tree/expression'),
+ Quoted = require('../tree/quoted'),
+ URL = require('../tree/url'),
+ functionRegistry = require('./function-registry');
- functionRegistry.add("svg-gradient", function(direction) {
+ functionRegistry.add('svg-gradient', function(direction) {
var stops,
gradientDirectionSvg,
- gradientType = "linear",
+ gradientType = 'linear',
rectangleDimension = 'x="0" y="0" width="1" height="1"',
renderEnv = {compress: false},
returner,
@@ -2514,9 +2551,9 @@ module.exports = function(environment) {
i, color, position, positionValue, alpha;
function throwArgumentDescriptor() {
- throw { type: "Argument",
- message: "svg-gradient expects direction, start_color [start_position], [color position,]...," +
- " end_color [end_position] or direction, color list" };
+ throw { type: 'Argument',
+ message: 'svg-gradient expects direction, start_color [start_position], [color position,]...,' +
+ ' end_color [end_position] or direction, color list' };
}
if (arguments.length == 2) {
@@ -2531,27 +2568,27 @@ module.exports = function(environment) {
}
switch (directionValue) {
- case "to bottom":
+ case 'to bottom':
gradientDirectionSvg = 'x1="0%" y1="0%" x2="0%" y2="100%"';
break;
- case "to right":
+ case 'to right':
gradientDirectionSvg = 'x1="0%" y1="0%" x2="100%" y2="0%"';
break;
- case "to bottom right":
+ case 'to bottom right':
gradientDirectionSvg = 'x1="0%" y1="0%" x2="100%" y2="100%"';
break;
- case "to top right":
+ case 'to top right':
gradientDirectionSvg = 'x1="0%" y1="100%" x2="100%" y2="0%"';
break;
- case "ellipse":
- case "ellipse at center":
- gradientType = "radial";
+ case 'ellipse':
+ case 'ellipse at center':
+ gradientType = 'radial';
gradientDirectionSvg = 'cx="50%" cy="50%" r="75%"';
rectangleDimension = 'x="-50" y="-50" width="101" height="101"';
break;
default:
- throw { type: "Argument", message: "svg-gradient direction must be 'to bottom', 'to right'," +
- " 'to bottom right', 'to top right' or 'ellipse at center'" };
+ throw { type: 'Argument', message: 'svg-gradient direction must be \'to bottom\', \'to right\',' +
+ ' \'to bottom right\', \'to top right\' or \'ellipse at center\'' };
}
returner = '' +
'