less 2.3.1 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/workspace.xml +277 -237
- package/.jscsrc +36 -1
- package/.travis.yml +1 -0
- package/CHANGELOG.md +14 -0
- package/Gruntfile.js +1 -1
- package/appveyor.yml +5 -0
- package/bin/lessc +8 -5
- package/bower.json +1 -1
- package/dist/less.js +909 -814
- package/dist/less.min.js +6 -6
- package/lib/less/contexts.js +2 -2
- package/lib/less/environment/abstract-file-manager.js +6 -6
- package/lib/less/environment/environment.js +2 -2
- package/lib/less/functions/color.js +13 -5
- package/lib/less/functions/math.js +1 -1
- package/lib/less/functions/number.js +2 -2
- package/lib/less/functions/types.js +18 -8
- package/lib/less/import-manager.js +5 -5
- package/lib/less/index.js +1 -1
- package/lib/less/less-error.js +1 -1
- package/lib/less/logger.js +2 -2
- package/lib/less/parse-tree.js +45 -45
- package/lib/less/parse.js +5 -2
- package/lib/less/parser/parser-input.js +3 -3
- package/lib/less/parser/parser.js +52 -18
- package/lib/less/plugin-manager.js +30 -3
- package/lib/less/render.js +5 -2
- package/lib/less/source-map-builder.js +4 -0
- package/lib/less/source-map-output.js +3 -3
- package/lib/less/transform-tree.js +4 -4
- package/lib/less/tree/anonymous.js +1 -1
- package/lib/less/tree/call.js +1 -1
- package/lib/less/tree/color.js +2 -2
- package/lib/less/tree/condition.js +8 -4
- package/lib/less/tree/dimension.js +4 -4
- package/lib/less/tree/element.js +1 -1
- package/lib/less/tree/expression.js +1 -1
- package/lib/less/tree/extend.js +3 -3
- package/lib/less/tree/javascript.js +2 -2
- package/lib/less/tree/media.js +20 -20
- package/lib/less/tree/mixin-call.js +2 -2
- package/lib/less/tree/mixin-definition.js +29 -8
- package/lib/less/tree/quoted.js +3 -3
- package/lib/less/tree/rule.js +1 -1
- package/lib/less/tree/ruleset.js +35 -28
- package/lib/less/tree/selector.js +1 -1
- package/lib/less/tree/unit.js +2 -0
- package/lib/less/tree/value.js +1 -1
- package/lib/less/visitors/extend-visitor.js +15 -14
- package/lib/less/visitors/import-sequencer.js +2 -2
- package/lib/less/visitors/import-visitor.js +2 -2
- package/lib/less/visitors/to-css-visitor.js +5 -5
- package/lib/less-browser/cache.js +2 -2
- package/lib/less-browser/file-manager.js +96 -96
- package/lib/less-browser/index.js +205 -205
- package/lib/less-browser/log-listener.js +2 -2
- package/lib/less-browser/utils.js +6 -6
- package/lib/less-node/file-manager.js +9 -4
- package/lib/less-node/index.js +3 -3
- package/lib/less-node/plugin-loader.js +3 -3
- package/lib/less-node/url-file-manager.js +5 -2
- package/lib/less-rhino/index.js +13 -9
- package/lib/source-map/source-map-0.1.31.js +1 -1
- package/package.json +1 -1
- package/test/browser/css/relative-urls/urls.css +1 -0
- package/test/browser/less/relative-urls/urls.less +1 -0
- package/test/browser/runner-browser-options.js +23 -23
- package/test/browser/runner-errors-spec.js +1 -1
- package/test/browser/runner-global-vars-spec.js +1 -1
- package/test/browser/runner-main-options.js +5 -5
- package/test/browser/runner-main-spec.js +1 -1
- package/test/copy-bom.js +35 -35
- package/test/css/functions.css +8 -0
- package/test/css/import-interpolation.css +1 -0
- package/test/css/mixins-important.css +6 -0
- package/test/css/selectors.css +5 -0
- package/test/css/static-urls/urls.css +1 -0
- package/test/css/urls.css +1 -0
- package/test/index.js +2 -1
- package/test/less/functions.less +13 -0
- package/test/less/import/imports/logo.less +1 -0
- package/test/less/mixins-important.less +17 -1
- package/test/less/selectors.less +10 -0
- package/test/less/sourcemaps-empty/empty.less +0 -0
- package/test/less/sourcemaps-empty/var-defs.less +1 -0
- package/test/less/urls.less +1 -1
- package/test/less-test.js +49 -27
- package/test/modify-vars.js +13 -13
- package/test/browser/less.js +0 -29
- package/test/less-bom/charsets.less +0 -3
- package/test/less-bom/colors.less +0 -98
- package/test/less-bom/comments.less +0 -102
- package/test/less-bom/comments2.less +0 -20
- package/test/less-bom/compression/compression.less +0 -36
- package/test/less-bom/css-3.less +0 -154
- package/test/less-bom/css-escapes.less +0 -33
- package/test/less-bom/css-guards.less +0 -103
- package/test/less-bom/css.less +0 -108
- package/test/less-bom/debug/import/test.less +0 -25
- package/test/less-bom/debug/linenumbers.less +0 -33
- package/test/less-bom/detached-rulesets.less +0 -103
- package/test/less-bom/empty.less +0 -1
- package/test/less-bom/errors/add-mixed-units.less +0 -3
- package/test/less-bom/errors/add-mixed-units.txt +0 -4
- package/test/less-bom/errors/add-mixed-units2.less +0 -3
- package/test/less-bom/errors/add-mixed-units2.txt +0 -4
- package/test/less-bom/errors/at-rules-undefined-var.less +0 -4
- package/test/less-bom/errors/at-rules-undefined-var.txt +0 -4
- package/test/less-bom/errors/bad-variable-declaration1.less +0 -1
- package/test/less-bom/errors/bad-variable-declaration1.txt +0 -2
- package/test/less-bom/errors/color-func-invalid-color.less +0 -3
- package/test/less-bom/errors/color-func-invalid-color.txt +0 -4
- package/test/less-bom/errors/color-invalid-hex-code.less +0 -3
- package/test/less-bom/errors/color-invalid-hex-code.txt +0 -4
- package/test/less-bom/errors/color-invalid-hex-code2.less +0 -3
- package/test/less-bom/errors/color-invalid-hex-code2.txt +0 -4
- package/test/less-bom/errors/css-guard-default-func.less +0 -4
- package/test/less-bom/errors/css-guard-default-func.txt +0 -4
- package/test/less-bom/errors/detached-ruleset-1.less +0 -6
- package/test/less-bom/errors/detached-ruleset-1.txt +0 -4
- package/test/less-bom/errors/detached-ruleset-2.less +0 -6
- package/test/less-bom/errors/detached-ruleset-2.txt +0 -4
- package/test/less-bom/errors/detached-ruleset-3.less +0 -4
- package/test/less-bom/errors/detached-ruleset-3.txt +0 -4
- package/test/less-bom/errors/detached-ruleset-4.less +0 -5
- package/test/less-bom/errors/detached-ruleset-4.txt +0 -4
- package/test/less-bom/errors/detached-ruleset-5.less +0 -4
- package/test/less-bom/errors/detached-ruleset-5.txt +0 -3
- package/test/less-bom/errors/detached-ruleset-6.less +0 -5
- package/test/less-bom/errors/detached-ruleset-6.txt +0 -4
- package/test/less-bom/errors/divide-mixed-units.less +0 -3
- package/test/less-bom/errors/divide-mixed-units.txt +0 -4
- package/test/less-bom/errors/extend-no-selector.less +0 -3
- package/test/less-bom/errors/extend-no-selector.txt +0 -3
- package/test/less-bom/errors/extend-not-at-end.less +0 -3
- package/test/less-bom/errors/extend-not-at-end.txt +0 -3
- package/test/less-bom/errors/import-malformed.less +0 -1
- package/test/less-bom/errors/import-malformed.txt +0 -3
- package/test/less-bom/errors/import-missing.less +0 -6
- package/test/less-bom/errors/import-missing.txt +0 -3
- package/test/less-bom/errors/import-no-semi.less +0 -1
- package/test/less-bom/errors/import-no-semi.txt +0 -2
- package/test/less-bom/errors/import-subfolder1.less +0 -1
- package/test/less-bom/errors/import-subfolder1.txt +0 -3
- package/test/less-bom/errors/import-subfolder2.less +0 -1
- package/test/less-bom/errors/import-subfolder2.txt +0 -4
- package/test/less-bom/errors/imports/import-subfolder1.less +0 -1
- package/test/less-bom/errors/imports/import-subfolder2.less +0 -1
- package/test/less-bom/errors/imports/import-test.less +0 -4
- package/test/less-bom/errors/imports/subfolder/mixin-not-defined.less +0 -1
- package/test/less-bom/errors/imports/subfolder/parse-error-curly-bracket.less +0 -1
- package/test/less-bom/errors/javascript-error.less +0 -3
- package/test/less-bom/errors/javascript-error.txt +0 -4
- package/test/less-bom/errors/javascript-undefined-var.less +0 -3
- package/test/less-bom/errors/javascript-undefined-var.txt +0 -4
- package/test/less-bom/errors/mixed-mixin-definition-args-1.less +0 -6
- package/test/less-bom/errors/mixed-mixin-definition-args-1.txt +0 -4
- package/test/less-bom/errors/mixed-mixin-definition-args-2.less +0 -6
- package/test/less-bom/errors/mixed-mixin-definition-args-2.txt +0 -4
- package/test/less-bom/errors/mixin-not-defined.less +0 -11
- package/test/less-bom/errors/mixin-not-defined.txt +0 -3
- package/test/less-bom/errors/mixin-not-matched.less +0 -6
- package/test/less-bom/errors/mixin-not-matched.txt +0 -3
- package/test/less-bom/errors/mixin-not-matched2.less +0 -6
- package/test/less-bom/errors/mixin-not-matched2.txt +0 -3
- package/test/less-bom/errors/mixin-not-visible-in-scope-1.less +0 -9
- package/test/less-bom/errors/mixin-not-visible-in-scope-1.txt +0 -4
- package/test/less-bom/errors/mixins-guards-default-func-1.less +0 -9
- package/test/less-bom/errors/mixins-guards-default-func-1.txt +0 -4
- package/test/less-bom/errors/mixins-guards-default-func-2.less +0 -9
- package/test/less-bom/errors/mixins-guards-default-func-2.txt +0 -4
- package/test/less-bom/errors/mixins-guards-default-func-3.less +0 -9
- package/test/less-bom/errors/mixins-guards-default-func-3.txt +0 -4
- package/test/less-bom/errors/multiple-guards-on-css-selectors.less +0 -4
- package/test/less-bom/errors/multiple-guards-on-css-selectors.txt +0 -4
- package/test/less-bom/errors/multiple-guards-on-css-selectors2.less +0 -4
- package/test/less-bom/errors/multiple-guards-on-css-selectors2.txt +0 -4
- package/test/less-bom/errors/multiply-mixed-units.less +0 -7
- package/test/less-bom/errors/multiply-mixed-units.txt +0 -4
- package/test/less-bom/errors/parens-error-1.less +0 -3
- package/test/less-bom/errors/parens-error-1.txt +0 -4
- package/test/less-bom/errors/parens-error-2.less +0 -3
- package/test/less-bom/errors/parens-error-2.txt +0 -4
- package/test/less-bom/errors/parens-error-3.less +0 -3
- package/test/less-bom/errors/parens-error-3.txt +0 -4
- package/test/less-bom/errors/parse-error-curly-bracket.less +0 -4
- package/test/less-bom/errors/parse-error-curly-bracket.txt +0 -4
- package/test/less-bom/errors/parse-error-extra-parens.less +0 -5
- package/test/less-bom/errors/parse-error-extra-parens.txt +0 -3
- package/test/less-bom/errors/parse-error-missing-bracket.less +0 -2
- package/test/less-bom/errors/parse-error-missing-bracket.txt +0 -3
- package/test/less-bom/errors/parse-error-missing-parens.less +0 -5
- package/test/less-bom/errors/parse-error-missing-parens.txt +0 -3
- package/test/less-bom/errors/parse-error-with-import.less +0 -13
- package/test/less-bom/errors/parse-error-with-import.txt +0 -4
- package/test/less-bom/errors/percentage-missing-space.less +0 -3
- package/test/less-bom/errors/percentage-missing-space.txt +0 -4
- package/test/less-bom/errors/property-asterisk-only-name.less +0 -3
- package/test/less-bom/errors/property-asterisk-only-name.txt +0 -4
- package/test/less-bom/errors/property-ie5-hack.less +0 -3
- package/test/less-bom/errors/property-ie5-hack.txt +0 -3
- package/test/less-bom/errors/property-in-root.less +0 -4
- package/test/less-bom/errors/property-in-root.txt +0 -4
- package/test/less-bom/errors/property-in-root2.less +0 -1
- package/test/less-bom/errors/property-in-root2.txt +0 -4
- package/test/less-bom/errors/property-in-root3.less +0 -4
- package/test/less-bom/errors/property-in-root3.txt +0 -3
- package/test/less-bom/errors/property-interp-not-defined.less +0 -1
- package/test/less-bom/errors/property-interp-not-defined.txt +0 -2
- package/test/less-bom/errors/recursive-variable.less +0 -1
- package/test/less-bom/errors/recursive-variable.txt +0 -2
- package/test/less-bom/errors/single-character.less +0 -1
- package/test/less-bom/errors/single-character.txt +0 -2
- package/test/less-bom/errors/svg-gradient1.less +0 -3
- package/test/less-bom/errors/svg-gradient1.txt +0 -4
- package/test/less-bom/errors/svg-gradient2.less +0 -3
- package/test/less-bom/errors/svg-gradient2.txt +0 -4
- package/test/less-bom/errors/svg-gradient3.less +0 -3
- package/test/less-bom/errors/svg-gradient3.txt +0 -4
- package/test/less-bom/errors/unit-function.less +0 -3
- package/test/less-bom/errors/unit-function.txt +0 -4
- package/test/less-bom/extend-chaining.less +0 -91
- package/test/less-bom/extend-clearfix.less +0 -19
- package/test/less-bom/extend-exact.less +0 -46
- package/test/less-bom/extend-media.less +0 -24
- package/test/less-bom/extend-nest.less +0 -65
- package/test/less-bom/extend-selector.less +0 -99
- package/test/less-bom/extend.less +0 -81
- package/test/less-bom/extract-and-length.less +0 -133
- package/test/less-bom/functions.less +0 -201
- package/test/less-bom/globalVars/extended.json +0 -5
- package/test/less-bom/globalVars/extended.less +0 -10
- package/test/less-bom/globalVars/simple.json +0 -3
- package/test/less-bom/globalVars/simple.less +0 -3
- package/test/less-bom/ie-filters.less +0 -15
- package/test/less-bom/import/deeper/deeper-2/url-import-2.less +0 -3
- package/test/less-bom/import/deeper/deeper-2/url-import.less +0 -1
- package/test/less-bom/import/deeper/import-once-test-a.less +0 -1
- package/test/less-bom/import/deeper/url-import.less +0 -1
- package/test/less-bom/import/import-and-relative-paths-test.less +0 -17
- package/test/less-bom/import/import-charset-test.less +0 -1
- package/test/less-bom/import/import-interpolation.less +0 -2
- package/test/less-bom/import/import-interpolation2.less +0 -5
- package/test/less-bom/import/import-once-test-c.less +0 -6
- package/test/less-bom/import/import-reference.less +0 -89
- package/test/less-bom/import/import-test-a.less +0 -4
- package/test/less-bom/import/import-test-b.less +0 -8
- package/test/less-bom/import/import-test-c.less +0 -6
- package/test/less-bom/import/import-test-d.css +0 -1
- package/test/less-bom/import/import-test-e.less +0 -2
- package/test/less-bom/import/import-test-f.less +0 -5
- package/test/less-bom/import/imports/font.less +0 -8
- package/test/less-bom/import/imports/logo.less +0 -5
- package/test/less-bom/import/interpolation-vars.less +0 -6
- package/test/less-bom/import/invalid-css.less +0 -1
- package/test/less-bom/import/urls.less +0 -1
- package/test/less-bom/import-inline.less +0 -3
- package/test/less-bom/import-interpolation.less +0 -8
- package/test/less-bom/import-once.less +0 -6
- package/test/less-bom/import-reference.less +0 -23
- package/test/less-bom/import.less +0 -30
- package/test/less-bom/include-path/include-path.less +0 -6
- package/test/less-bom/javascript.less +0 -38
- package/test/less-bom/lazy-eval.less +0 -6
- package/test/less-bom/legacy/legacy.less +0 -7
- package/test/less-bom/media.less +0 -234
- package/test/less-bom/merge.less +0 -78
- package/test/less-bom/mixins-args.less +0 -215
- package/test/less-bom/mixins-closure.less +0 -26
- package/test/less-bom/mixins-guards-default-func.less +0 -195
- package/test/less-bom/mixins-guards.less +0 -271
- package/test/less-bom/mixins-important.less +0 -37
- package/test/less-bom/mixins-interpolated.less +0 -75
- package/test/less-bom/mixins-named-args.less +0 -36
- package/test/less-bom/mixins-nested.less +0 -22
- package/test/less-bom/mixins-pattern.less +0 -102
- package/test/less-bom/mixins.less +0 -145
- package/test/less-bom/modifyVars/extended.json +0 -5
- package/test/less-bom/modifyVars/extended.less +0 -11
- package/test/less-bom/nested-gradient-with-svg-gradient/mixin-consumer.less +0 -5
- package/test/less-bom/nested-gradient-with-svg-gradient/svg-gradient-mixin.less +0 -15
- package/test/less-bom/no-js-errors/no-js-errors.less +0 -3
- package/test/less-bom/no-js-errors/no-js-errors.txt +0 -4
- package/test/less-bom/no-output.less +0 -2
- package/test/less-bom/operations.less +0 -62
- package/test/less-bom/parens.less +0 -45
- package/test/less-bom/property-name-interp.less +0 -56
- package/test/less-bom/rulesets.less +0 -30
- package/test/less-bom/scope.less +0 -104
- package/test/less-bom/selectors.less +0 -174
- package/test/less-bom/sourcemaps/basic.json +0 -3
- package/test/less-bom/sourcemaps/basic.less +0 -27
- package/test/less-bom/sourcemaps/imported.css +0 -7
- package/test/less-bom/static-urls/urls.less +0 -33
- package/test/less-bom/strict-units/strict-units.less +0 -4
- package/test/less-bom/strings.less +0 -73
- package/test/less-bom/url-args/urls.less +0 -63
- package/test/less-bom/urls.less +0 -94
- package/test/less-bom/variables-in-at-rules.less +0 -20
- package/test/less-bom/variables.less +0 -119
- package/test/less-bom/whitespace.less +0 -44
package/dist/less.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Less - Leaner CSS v2.
|
|
2
|
+
* Less - Leaner CSS v2.4.0
|
|
3
3
|
* http://lesscss.org
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2009-2015, Alexis Sellier <self@cloudhead.net>
|
|
@@ -85,7 +85,7 @@ if (options.onReady) {
|
|
|
85
85
|
}
|
|
86
86
|
);
|
|
87
87
|
}
|
|
88
|
-
},{"./add-default-options":1,"./index":7,"promise/polyfill.js":
|
|
88
|
+
},{"./add-default-options":1,"./index":7,"promise/polyfill.js":"promise/polyfill.js"}],3:[function(require,module,exports){
|
|
89
89
|
var utils = require("./utils");
|
|
90
90
|
module.exports = {
|
|
91
91
|
createCSS: function (document, styles, sheet) {
|
|
@@ -158,13 +158,13 @@ module.exports = function(window, options, logger) {
|
|
|
158
158
|
var cache = null;
|
|
159
159
|
if (options.env !== 'development') {
|
|
160
160
|
try {
|
|
161
|
-
cache = (typeof
|
|
161
|
+
cache = (typeof window.localStorage === 'undefined') ? null : window.localStorage;
|
|
162
162
|
} catch (_) {}
|
|
163
163
|
}
|
|
164
164
|
return {
|
|
165
165
|
setCSS: function(path, lastModified, styles) {
|
|
166
166
|
if (cache) {
|
|
167
|
-
logger.info('saving ' + path+ ' to cache.');
|
|
167
|
+
logger.info('saving ' + path + ' to cache.');
|
|
168
168
|
try {
|
|
169
169
|
cache.setItem(path, styles);
|
|
170
170
|
cache.setItem(path + ':timestamp', lastModified);
|
|
@@ -365,120 +365,120 @@ module.exports = function(window, less, options) {
|
|
|
365
365
|
|
|
366
366
|
module.exports = function(options, logger) {
|
|
367
367
|
|
|
368
|
-
var AbstractFileManager = require("../less/environment/abstract-file-manager.js");
|
|
368
|
+
var AbstractFileManager = require("../less/environment/abstract-file-manager.js");
|
|
369
369
|
|
|
370
|
-
var fileCache = {};
|
|
370
|
+
var fileCache = {};
|
|
371
371
|
|
|
372
|
-
//TODOS - move log somewhere. pathDiff and doing something similar in node. use pathDiff in the other browser file for the initial load
|
|
372
|
+
//TODOS - move log somewhere. pathDiff and doing something similar in node. use pathDiff in the other browser file for the initial load
|
|
373
373
|
|
|
374
|
-
function getXMLHttpRequest() {
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
374
|
+
function getXMLHttpRequest() {
|
|
375
|
+
if (window.XMLHttpRequest && (window.location.protocol !== "file:" || !("ActiveXObject" in window))) {
|
|
376
|
+
return new XMLHttpRequest();
|
|
377
|
+
} else {
|
|
378
|
+
try {
|
|
379
|
+
/*global ActiveXObject */
|
|
380
|
+
return new ActiveXObject("Microsoft.XMLHTTP");
|
|
381
|
+
} catch (e) {
|
|
382
|
+
logger.error("browser doesn't support AJAX.");
|
|
383
|
+
return null;
|
|
384
|
+
}
|
|
384
385
|
}
|
|
385
386
|
}
|
|
386
|
-
}
|
|
387
387
|
|
|
388
|
-
var FileManager = function() {
|
|
389
|
-
};
|
|
388
|
+
var FileManager = function() {
|
|
389
|
+
};
|
|
390
390
|
|
|
391
|
-
FileManager.prototype = new AbstractFileManager();
|
|
391
|
+
FileManager.prototype = new AbstractFileManager();
|
|
392
392
|
|
|
393
|
-
FileManager.prototype.alwaysMakePathsAbsolute = function alwaysMakePathsAbsolute() {
|
|
394
|
-
|
|
395
|
-
};
|
|
396
|
-
FileManager.prototype.join = function join(basePath, laterPath) {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
};
|
|
402
|
-
FileManager.prototype.doXHR = function doXHR(url, type, callback, errback) {
|
|
393
|
+
FileManager.prototype.alwaysMakePathsAbsolute = function alwaysMakePathsAbsolute() {
|
|
394
|
+
return true;
|
|
395
|
+
};
|
|
396
|
+
FileManager.prototype.join = function join(basePath, laterPath) {
|
|
397
|
+
if (!basePath) {
|
|
398
|
+
return laterPath;
|
|
399
|
+
}
|
|
400
|
+
return this.extractUrlParts(laterPath, basePath).path;
|
|
401
|
+
};
|
|
402
|
+
FileManager.prototype.doXHR = function doXHR(url, type, callback, errback) {
|
|
403
403
|
|
|
404
|
-
|
|
405
|
-
|
|
404
|
+
var xhr = getXMLHttpRequest();
|
|
405
|
+
var async = options.isFileProtocol ? options.fileAsync : options.async;
|
|
406
406
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
407
|
+
if (typeof xhr.overrideMimeType === 'function') {
|
|
408
|
+
xhr.overrideMimeType('text/css');
|
|
409
|
+
}
|
|
410
|
+
logger.debug("XHR: Getting '" + url + "'");
|
|
411
|
+
xhr.open('GET', url, async);
|
|
412
|
+
xhr.setRequestHeader('Accept', type || 'text/x-less, text/css; q=0.9, */*; q=0.5');
|
|
413
|
+
xhr.send(null);
|
|
414
414
|
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
415
|
+
function handleResponse(xhr, callback, errback) {
|
|
416
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
417
|
+
callback(xhr.responseText,
|
|
418
|
+
xhr.getResponseHeader("Last-Modified"));
|
|
419
|
+
} else if (typeof errback === 'function') {
|
|
420
|
+
errback(xhr.status, url);
|
|
421
|
+
}
|
|
421
422
|
}
|
|
422
|
-
}
|
|
423
423
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
424
|
+
if (options.isFileProtocol && !options.fileAsync) {
|
|
425
|
+
if (xhr.status === 0 || (xhr.status >= 200 && xhr.status < 300)) {
|
|
426
|
+
callback(xhr.responseText);
|
|
427
|
+
} else {
|
|
428
|
+
errback(xhr.status, url);
|
|
429
|
+
}
|
|
430
|
+
} else if (async) {
|
|
431
|
+
xhr.onreadystatechange = function () {
|
|
432
|
+
if (xhr.readyState == 4) {
|
|
433
|
+
handleResponse(xhr, callback, errback);
|
|
434
|
+
}
|
|
435
|
+
};
|
|
427
436
|
} else {
|
|
428
|
-
|
|
437
|
+
handleResponse(xhr, callback, errback);
|
|
429
438
|
}
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
}
|
|
435
|
-
};
|
|
436
|
-
} else {
|
|
437
|
-
handleResponse(xhr, callback, errback);
|
|
438
|
-
}
|
|
439
|
-
};
|
|
440
|
-
FileManager.prototype.supports = function(filename, currentDirectory, options, environment) {
|
|
441
|
-
return true;
|
|
442
|
-
};
|
|
439
|
+
};
|
|
440
|
+
FileManager.prototype.supports = function(filename, currentDirectory, options, environment) {
|
|
441
|
+
return true;
|
|
442
|
+
};
|
|
443
443
|
|
|
444
|
-
FileManager.prototype.clearFileCache = function() {
|
|
445
|
-
|
|
446
|
-
};
|
|
444
|
+
FileManager.prototype.clearFileCache = function() {
|
|
445
|
+
fileCache = {};
|
|
446
|
+
};
|
|
447
447
|
|
|
448
|
-
FileManager.prototype.loadFile = function loadFile(filename, currentDirectory, options, environment, callback) {
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
448
|
+
FileManager.prototype.loadFile = function loadFile(filename, currentDirectory, options, environment, callback) {
|
|
449
|
+
if (currentDirectory && !this.isPathAbsolute(filename)) {
|
|
450
|
+
filename = currentDirectory + filename;
|
|
451
|
+
}
|
|
452
452
|
|
|
453
|
-
|
|
453
|
+
options = options || {};
|
|
454
454
|
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
455
|
+
// sheet may be set to the stylesheet for the initial load or a collection of properties including
|
|
456
|
+
// some context variables for imports
|
|
457
|
+
var hrefParts = this.extractUrlParts(filename, window.location.href);
|
|
458
|
+
var href = hrefParts.url;
|
|
459
459
|
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
460
|
+
if (options.useFileCache && fileCache[href]) {
|
|
461
|
+
try {
|
|
462
|
+
var lessText = fileCache[href];
|
|
463
|
+
callback(null, { contents: lessText, filename: href, webInfo: { lastModified: new Date() }});
|
|
464
|
+
} catch (e) {
|
|
465
|
+
callback({filename: href, message: "Error loading file " + href + " error was " + e.message});
|
|
466
|
+
}
|
|
467
|
+
return;
|
|
466
468
|
}
|
|
467
|
-
return;
|
|
468
|
-
}
|
|
469
469
|
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
470
|
+
this.doXHR(href, options.mime, function doXHRCallback(data, lastModified) {
|
|
471
|
+
// per file cache
|
|
472
|
+
fileCache[href] = data;
|
|
473
473
|
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
};
|
|
474
|
+
// Use remote copy (re-parse)
|
|
475
|
+
callback(null, { contents: data, filename: href, webInfo: { lastModified: lastModified }});
|
|
476
|
+
}, function doXHRError(status, url) {
|
|
477
|
+
callback({ type: 'File', message: "'" + url + "' wasn't found (" + status + ")", href: href });
|
|
478
|
+
});
|
|
479
|
+
};
|
|
480
480
|
|
|
481
|
-
return FileManager;
|
|
481
|
+
return FileManager;
|
|
482
482
|
};
|
|
483
483
|
|
|
484
484
|
},{"../less/environment/abstract-file-manager.js":14}],7:[function(require,module,exports){
|
|
@@ -490,252 +490,252 @@ var addDataAttr = require("./utils").addDataAttr,
|
|
|
490
490
|
browser = require("./browser");
|
|
491
491
|
|
|
492
492
|
module.exports = function(window, options) {
|
|
493
|
-
var document = window.document;
|
|
494
|
-
var less = require('../less')();
|
|
495
|
-
module.exports = less;
|
|
496
|
-
less.options = options;
|
|
497
|
-
var environment = less.environment,
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
environment.addFileManager(fileManager);
|
|
501
|
-
less.FileManager = FileManager;
|
|
502
|
-
|
|
503
|
-
require("./log-listener")(less, options);
|
|
504
|
-
var errors = require("./error-reporting")(window, less, options);
|
|
505
|
-
var cache = less.cache = options.cache || require("./cache")(window, options, less.logger);
|
|
506
|
-
|
|
507
|
-
//Setup user functions
|
|
508
|
-
if (options.functions) {
|
|
509
|
-
less.functions.functionRegistry.addMultiple(options.functions);
|
|
510
|
-
}
|
|
493
|
+
var document = window.document;
|
|
494
|
+
var less = require('../less')();
|
|
495
|
+
//module.exports = less;
|
|
496
|
+
less.options = options;
|
|
497
|
+
var environment = less.environment,
|
|
498
|
+
FileManager = require("./file-manager")(options, less.logger),
|
|
499
|
+
fileManager = new FileManager();
|
|
500
|
+
environment.addFileManager(fileManager);
|
|
501
|
+
less.FileManager = FileManager;
|
|
511
502
|
|
|
512
|
-
|
|
503
|
+
require("./log-listener")(less, options);
|
|
504
|
+
var errors = require("./error-reporting")(window, less, options);
|
|
505
|
+
var cache = less.cache = options.cache || require("./cache")(window, options, less.logger);
|
|
513
506
|
|
|
514
|
-
|
|
515
|
-
if (options.
|
|
516
|
-
|
|
507
|
+
//Setup user functions
|
|
508
|
+
if (options.functions) {
|
|
509
|
+
less.functions.functionRegistry.addMultiple(options.functions);
|
|
517
510
|
}
|
|
518
|
-
return styles;
|
|
519
|
-
}
|
|
520
511
|
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
if (
|
|
525
|
-
|
|
512
|
+
var typePattern = /^text\/(x-)?less$/;
|
|
513
|
+
|
|
514
|
+
function postProcessCSS(styles) {
|
|
515
|
+
if (options.postProcessor && typeof options.postProcessor === 'function') {
|
|
516
|
+
styles = options.postProcessor.call(styles, styles) || styles;
|
|
526
517
|
}
|
|
518
|
+
return styles;
|
|
527
519
|
}
|
|
528
|
-
return cloned;
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
// only really needed for phantom
|
|
532
|
-
function bind(func, thisArg) {
|
|
533
|
-
var curryArgs = Array.prototype.slice.call(arguments, 2);
|
|
534
|
-
return function() {
|
|
535
|
-
var args = curryArgs.concat(Array.prototype.slice.call(arguments, 0));
|
|
536
|
-
return func.apply(thisArg, args);
|
|
537
|
-
};
|
|
538
|
-
}
|
|
539
520
|
|
|
540
|
-
function
|
|
541
|
-
|
|
542
|
-
|
|
521
|
+
function clone(obj) {
|
|
522
|
+
var cloned = {};
|
|
523
|
+
for (var prop in obj) {
|
|
524
|
+
if (obj.hasOwnProperty(prop)) {
|
|
525
|
+
cloned[prop] = obj[prop];
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
return cloned;
|
|
529
|
+
}
|
|
543
530
|
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
531
|
+
// only really needed for phantom
|
|
532
|
+
function bind(func, thisArg) {
|
|
533
|
+
var curryArgs = Array.prototype.slice.call(arguments, 2);
|
|
534
|
+
return function() {
|
|
535
|
+
var args = curryArgs.concat(Array.prototype.slice.call(arguments, 0));
|
|
536
|
+
return func.apply(thisArg, args);
|
|
537
|
+
};
|
|
538
|
+
}
|
|
551
539
|
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
540
|
+
function loadStyles(modifyVars) {
|
|
541
|
+
var styles = document.getElementsByTagName('style'),
|
|
542
|
+
style;
|
|
543
|
+
|
|
544
|
+
for (var i = 0; i < styles.length; i++) {
|
|
545
|
+
style = styles[i];
|
|
546
|
+
if (style.type.match(typePattern)) {
|
|
547
|
+
var instanceOptions = clone(options);
|
|
548
|
+
instanceOptions.modifyVars = modifyVars;
|
|
549
|
+
var lessText = style.innerHTML || '';
|
|
550
|
+
instanceOptions.filename = document.location.href.replace(/#.*$/, '');
|
|
551
|
+
|
|
552
|
+
/*jshint loopfunc:true */
|
|
553
|
+
// use closure to store current style
|
|
554
|
+
less.render(lessText, instanceOptions,
|
|
555
|
+
bind(function(style, e, result) {
|
|
556
|
+
if (e) {
|
|
557
|
+
errors.add(e, "inline");
|
|
562
558
|
} else {
|
|
563
|
-
style.
|
|
559
|
+
style.type = 'text/css';
|
|
560
|
+
if (style.styleSheet) {
|
|
561
|
+
style.styleSheet.cssText = result.css;
|
|
562
|
+
} else {
|
|
563
|
+
style.innerHTML = result.css;
|
|
564
|
+
}
|
|
564
565
|
}
|
|
565
|
-
}
|
|
566
|
-
|
|
566
|
+
}, null, style));
|
|
567
|
+
}
|
|
567
568
|
}
|
|
568
569
|
}
|
|
569
|
-
}
|
|
570
570
|
|
|
571
|
-
function loadStyleSheet(sheet, callback, reload, remaining, modifyVars) {
|
|
571
|
+
function loadStyleSheet(sheet, callback, reload, remaining, modifyVars) {
|
|
572
572
|
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
573
|
+
var instanceOptions = clone(options);
|
|
574
|
+
addDataAttr(instanceOptions, sheet);
|
|
575
|
+
instanceOptions.mime = sheet.type;
|
|
576
576
|
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
577
|
+
if (modifyVars) {
|
|
578
|
+
instanceOptions.modifyVars = modifyVars;
|
|
579
|
+
}
|
|
580
580
|
|
|
581
|
-
|
|
581
|
+
function loadInitialFileCallback(loadedFile) {
|
|
582
582
|
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
583
|
+
var data = loadedFile.contents,
|
|
584
|
+
path = loadedFile.filename,
|
|
585
|
+
webInfo = loadedFile.webInfo;
|
|
586
586
|
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
587
|
+
var newFileInfo = {
|
|
588
|
+
currentDirectory: fileManager.getPath(path),
|
|
589
|
+
filename: path,
|
|
590
|
+
rootFilename: path,
|
|
591
|
+
relativeUrls: instanceOptions.relativeUrls};
|
|
592
|
+
|
|
593
|
+
newFileInfo.entryPath = newFileInfo.currentDirectory;
|
|
594
|
+
newFileInfo.rootpath = instanceOptions.rootpath || newFileInfo.currentDirectory;
|
|
595
|
+
|
|
596
|
+
if (webInfo) {
|
|
597
|
+
webInfo.remaining = remaining;
|
|
598
|
+
|
|
599
|
+
if (!instanceOptions.modifyVars) {
|
|
600
|
+
var css = cache.getCSS(path, webInfo);
|
|
601
|
+
if (!reload && css) {
|
|
602
|
+
webInfo.local = true;
|
|
603
|
+
callback(null, css, data, sheet, webInfo, path);
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
605
606
|
}
|
|
606
607
|
}
|
|
607
|
-
}
|
|
608
608
|
|
|
609
|
-
|
|
610
|
-
|
|
609
|
+
//TODO add tests around how this behaves when reloading
|
|
610
|
+
errors.remove(path);
|
|
611
611
|
|
|
612
|
-
|
|
613
|
-
|
|
612
|
+
instanceOptions.rootFileInfo = newFileInfo;
|
|
613
|
+
less.render(data, instanceOptions, function(e, result) {
|
|
614
|
+
if (e) {
|
|
615
|
+
e.href = path;
|
|
616
|
+
callback(e);
|
|
617
|
+
} else {
|
|
618
|
+
result.css = postProcessCSS(result.css);
|
|
619
|
+
if (!instanceOptions.modifyVars) {
|
|
620
|
+
cache.setCSS(sheet.href, webInfo.lastModified, result.css);
|
|
621
|
+
}
|
|
622
|
+
callback(null, result.css, data, sheet, webInfo, path);
|
|
623
|
+
}
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
fileManager.loadFile(sheet.href, null, instanceOptions, environment, function(e, loadedFile) {
|
|
614
628
|
if (e) {
|
|
615
|
-
e.href = path;
|
|
616
629
|
callback(e);
|
|
617
|
-
|
|
618
|
-
result.css = postProcessCSS(result.css);
|
|
619
|
-
if (!instanceOptions.modifyVars) {
|
|
620
|
-
cache.setCSS(sheet.href, webInfo.lastModified, result.css);
|
|
621
|
-
}
|
|
622
|
-
callback(null, result.css, data, sheet, webInfo, path);
|
|
630
|
+
return;
|
|
623
631
|
}
|
|
632
|
+
loadInitialFileCallback(loadedFile);
|
|
624
633
|
});
|
|
625
634
|
}
|
|
626
635
|
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
callback(
|
|
630
|
-
return;
|
|
636
|
+
function loadStyleSheets(callback, reload, modifyVars) {
|
|
637
|
+
for (var i = 0; i < less.sheets.length; i++) {
|
|
638
|
+
loadStyleSheet(less.sheets[i], callback, reload, less.sheets.length - (i + 1), modifyVars);
|
|
631
639
|
}
|
|
632
|
-
loadInitialFileCallback(loadedFile);
|
|
633
|
-
});
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
function loadStyleSheets(callback, reload, modifyVars) {
|
|
637
|
-
for (var i = 0; i < less.sheets.length; i++) {
|
|
638
|
-
loadStyleSheet(less.sheets[i], callback, reload, less.sheets.length - (i + 1), modifyVars);
|
|
639
640
|
}
|
|
640
|
-
}
|
|
641
641
|
|
|
642
|
-
function initRunningMode(){
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
//
|
|
660
|
-
// Watch mode
|
|
661
|
-
//
|
|
662
|
-
less.watch = function () {
|
|
663
|
-
if (!less.watchMode ){
|
|
664
|
-
less.env = 'development';
|
|
665
|
-
initRunningMode();
|
|
642
|
+
function initRunningMode() {
|
|
643
|
+
if (less.env === 'development') {
|
|
644
|
+
less.watchTimer = setInterval(function () {
|
|
645
|
+
if (less.watchMode) {
|
|
646
|
+
fileManager.clearFileCache();
|
|
647
|
+
loadStyleSheets(function (e, css, _, sheet, webInfo) {
|
|
648
|
+
if (e) {
|
|
649
|
+
errors.add(e, e.href || sheet.href);
|
|
650
|
+
} else if (css) {
|
|
651
|
+
browser.createCSS(window.document, css, sheet);
|
|
652
|
+
}
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
}, options.poll);
|
|
656
|
+
}
|
|
666
657
|
}
|
|
667
|
-
this.watchMode = true;
|
|
668
|
-
return true;
|
|
669
|
-
};
|
|
670
658
|
|
|
671
|
-
|
|
659
|
+
//
|
|
660
|
+
// Watch mode
|
|
661
|
+
//
|
|
662
|
+
less.watch = function () {
|
|
663
|
+
if (!less.watchMode ) {
|
|
664
|
+
less.env = 'development';
|
|
665
|
+
initRunningMode();
|
|
666
|
+
}
|
|
667
|
+
this.watchMode = true;
|
|
668
|
+
return true;
|
|
669
|
+
};
|
|
672
670
|
|
|
673
|
-
|
|
674
|
-
// Get all <link> tags with the 'rel' attribute set to "stylesheet/less"
|
|
675
|
-
//
|
|
676
|
-
less.registerStylesheets = function() {
|
|
677
|
-
return new Promise(function(resolve, reject) {
|
|
678
|
-
var links = document.getElementsByTagName('link');
|
|
679
|
-
less.sheets = [];
|
|
671
|
+
less.unwatch = function () {clearInterval(less.watchTimer); this.watchMode = false; return false; };
|
|
680
672
|
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
673
|
+
//
|
|
674
|
+
// Get all <link> tags with the 'rel' attribute set to "stylesheet/less"
|
|
675
|
+
//
|
|
676
|
+
less.registerStylesheets = function() {
|
|
677
|
+
return new Promise(function(resolve, reject) {
|
|
678
|
+
var links = document.getElementsByTagName('link');
|
|
679
|
+
less.sheets = [];
|
|
680
|
+
|
|
681
|
+
for (var i = 0; i < links.length; i++) {
|
|
682
|
+
if (links[i].rel === 'stylesheet/less' || (links[i].rel.match(/stylesheet/) &&
|
|
683
|
+
(links[i].type.match(typePattern)))) {
|
|
684
|
+
less.sheets.push(links[i]);
|
|
685
|
+
}
|
|
685
686
|
}
|
|
686
|
-
}
|
|
687
687
|
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
};
|
|
688
|
+
resolve();
|
|
689
|
+
});
|
|
690
|
+
};
|
|
691
691
|
|
|
692
|
-
//
|
|
693
|
-
// With this function, it's possible to alter variables and re-render
|
|
694
|
-
// CSS without reloading less-files
|
|
695
|
-
//
|
|
696
|
-
less.modifyVars = function(record) {
|
|
697
|
-
|
|
698
|
-
};
|
|
692
|
+
//
|
|
693
|
+
// With this function, it's possible to alter variables and re-render
|
|
694
|
+
// CSS without reloading less-files
|
|
695
|
+
//
|
|
696
|
+
less.modifyVars = function(record) {
|
|
697
|
+
return less.refresh(true, record, false);
|
|
698
|
+
};
|
|
699
699
|
|
|
700
|
-
less.refresh = function (reload, modifyVars, clearFileCache) {
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
700
|
+
less.refresh = function (reload, modifyVars, clearFileCache) {
|
|
701
|
+
if ((reload || clearFileCache) && clearFileCache !== false) {
|
|
702
|
+
fileManager.clearFileCache();
|
|
703
|
+
}
|
|
704
|
+
return new Promise(function (resolve, reject) {
|
|
705
|
+
var startTime, endTime, totalMilliseconds;
|
|
706
|
+
startTime = endTime = new Date();
|
|
707
707
|
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
708
|
+
loadStyleSheets(function (e, css, _, sheet, webInfo) {
|
|
709
|
+
if (e) {
|
|
710
|
+
errors.add(e, e.href || sheet.href);
|
|
711
|
+
reject(e);
|
|
712
|
+
return;
|
|
713
|
+
}
|
|
714
|
+
if (webInfo.local) {
|
|
715
|
+
less.logger.info("loading " + sheet.href + " from cache.");
|
|
716
|
+
} else {
|
|
717
|
+
less.logger.info("rendered " + sheet.href + " successfully.");
|
|
718
|
+
}
|
|
719
|
+
browser.createCSS(window.document, css, sheet);
|
|
720
|
+
less.logger.info("css for " + sheet.href + " generated in " + (new Date() - endTime) + 'ms');
|
|
721
|
+
if (webInfo.remaining === 0) {
|
|
722
|
+
totalMilliseconds = new Date() - startTime;
|
|
723
|
+
less.logger.info("less has finished. css generated in " + totalMilliseconds + 'ms');
|
|
724
|
+
resolve({
|
|
725
|
+
startTime: startTime,
|
|
726
|
+
endTime: endTime,
|
|
727
|
+
totalMilliseconds: totalMilliseconds,
|
|
728
|
+
sheets: less.sheets.length
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
endTime = new Date();
|
|
732
|
+
}, reload, modifyVars);
|
|
733
733
|
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
};
|
|
734
|
+
loadStyles(modifyVars);
|
|
735
|
+
});
|
|
736
|
+
};
|
|
737
737
|
|
|
738
|
-
less.refreshStyles = loadStyles;
|
|
738
|
+
less.refreshStyles = loadStyles;
|
|
739
739
|
return less;
|
|
740
740
|
};
|
|
741
741
|
|
|
@@ -753,7 +753,7 @@ module.exports = function(less, options) {
|
|
|
753
753
|
// 1 - Errors
|
|
754
754
|
// 0 - None
|
|
755
755
|
// Defaults to 2
|
|
756
|
-
options.logLevel = typeof
|
|
756
|
+
options.logLevel = typeof options.logLevel !== 'undefined' ? options.logLevel : (options.env === 'development' ? logLevel_info : logLevel_error);
|
|
757
757
|
|
|
758
758
|
if (!options.loggers) {
|
|
759
759
|
options.loggers = [{
|
|
@@ -779,7 +779,7 @@ module.exports = function(less, options) {
|
|
|
779
779
|
}
|
|
780
780
|
}];
|
|
781
781
|
}
|
|
782
|
-
for(var i = 0; i < options.loggers.length; i++) {
|
|
782
|
+
for (var i = 0; i < options.loggers.length; i++) {
|
|
783
783
|
less.logger.addListener(options.loggers[i]);
|
|
784
784
|
}
|
|
785
785
|
};
|
|
@@ -787,12 +787,12 @@ module.exports = function(less, options) {
|
|
|
787
787
|
},{}],9:[function(require,module,exports){
|
|
788
788
|
module.exports = {
|
|
789
789
|
extractId: function(href) {
|
|
790
|
-
return href.replace(/^[a-z-]+:\/+?[^\/]+/, ''
|
|
791
|
-
.replace(/[\?\&]livereload=\w+/, ''
|
|
792
|
-
.replace(/^\//,
|
|
793
|
-
.replace(/\.[a-zA-Z]+$/,
|
|
794
|
-
.replace(/[^\.\w-]+/g,
|
|
795
|
-
.replace(/\./g,
|
|
790
|
+
return href.replace(/^[a-z-]+:\/+?[^\/]+/, '') // Remove protocol & domain
|
|
791
|
+
.replace(/[\?\&]livereload=\w+/, '') // Remove LiveReload cachebuster
|
|
792
|
+
.replace(/^\//, '') // Remove root /
|
|
793
|
+
.replace(/\.[a-zA-Z]+$/, '') // Remove simple extension
|
|
794
|
+
.replace(/[^\.\w-]+/g, '-') // Replace illegal characters
|
|
795
|
+
.replace(/\./g, ':'); // Replace dots with colons(for valid id)
|
|
796
796
|
},
|
|
797
797
|
addDataAttr: function(options, tag) {
|
|
798
798
|
for (var opt in tag.dataset) {
|
|
@@ -817,7 +817,7 @@ module.exports = contexts;
|
|
|
817
817
|
var copyFromOriginal = function copyFromOriginal(original, destination, propertiesToCopy) {
|
|
818
818
|
if (!original) { return; }
|
|
819
819
|
|
|
820
|
-
for(var i = 0; i < propertiesToCopy.length; i++) {
|
|
820
|
+
for (var i = 0; i < propertiesToCopy.length; i++) {
|
|
821
821
|
if (original.hasOwnProperty(propertiesToCopy[i])) {
|
|
822
822
|
destination[propertiesToCopy[i]] = original[propertiesToCopy[i]];
|
|
823
823
|
}
|
|
@@ -890,7 +890,7 @@ contexts.Eval.prototype.isMathOn = function () {
|
|
|
890
890
|
};
|
|
891
891
|
|
|
892
892
|
contexts.Eval.prototype.isPathRelative = function (path) {
|
|
893
|
-
return !/^(?:[a-z-]
|
|
893
|
+
return !/^(?:[a-z-]+:|\/|#)/i.test(path);
|
|
894
894
|
};
|
|
895
895
|
|
|
896
896
|
contexts.Eval.prototype.normalizePath = function( path ) {
|
|
@@ -1133,7 +1133,7 @@ abstractFileManager.prototype.alwaysMakePathsAbsolute = function() {
|
|
|
1133
1133
|
};
|
|
1134
1134
|
|
|
1135
1135
|
abstractFileManager.prototype.isPathAbsolute = function(filename) {
|
|
1136
|
-
return (/^(?:[a-z-]
|
|
1136
|
+
return (/^(?:[a-z-]+:|\/|\\|#)/i).test(filename);
|
|
1137
1137
|
};
|
|
1138
1138
|
|
|
1139
1139
|
abstractFileManager.prototype.join = function(basePath, laterPath) {
|
|
@@ -1152,15 +1152,15 @@ abstractFileManager.prototype.pathDiff = function pathDiff(url, baseUrl) {
|
|
|
1152
1152
|
return "";
|
|
1153
1153
|
}
|
|
1154
1154
|
max = Math.max(baseUrlParts.directories.length, urlParts.directories.length);
|
|
1155
|
-
for(i = 0; i < max; i++) {
|
|
1155
|
+
for (i = 0; i < max; i++) {
|
|
1156
1156
|
if (baseUrlParts.directories[i] !== urlParts.directories[i]) { break; }
|
|
1157
1157
|
}
|
|
1158
1158
|
baseUrlDirectories = baseUrlParts.directories.slice(i);
|
|
1159
1159
|
urlDirectories = urlParts.directories.slice(i);
|
|
1160
|
-
for(i = 0; i < baseUrlDirectories.length - 1; i++) {
|
|
1160
|
+
for (i = 0; i < baseUrlDirectories.length - 1; i++) {
|
|
1161
1161
|
diff += "../";
|
|
1162
1162
|
}
|
|
1163
|
-
for(i = 0; i < urlDirectories.length - 1; i++) {
|
|
1163
|
+
for (i = 0; i < urlDirectories.length - 1; i++) {
|
|
1164
1164
|
diff += urlDirectories[i] + "/";
|
|
1165
1165
|
}
|
|
1166
1166
|
return diff;
|
|
@@ -1197,14 +1197,14 @@ abstractFileManager.prototype.extractUrlParts = function extractUrlParts(url, ba
|
|
|
1197
1197
|
directories = urlParts[3].replace(/\\/g, "/").split("/");
|
|
1198
1198
|
|
|
1199
1199
|
// extract out . before .. so .. doesn't absorb a non-directory
|
|
1200
|
-
for(i = 0; i < directories.length; i++) {
|
|
1200
|
+
for (i = 0; i < directories.length; i++) {
|
|
1201
1201
|
if (directories[i] === ".") {
|
|
1202
1202
|
directories.splice(i, 1);
|
|
1203
1203
|
i -= 1;
|
|
1204
1204
|
}
|
|
1205
1205
|
}
|
|
1206
1206
|
|
|
1207
|
-
for(i = 0; i < directories.length; i++) {
|
|
1207
|
+
for (i = 0; i < directories.length; i++) {
|
|
1208
1208
|
if (directories[i] === ".." && i > 0) {
|
|
1209
1209
|
directories.splice(i - 1, 2);
|
|
1210
1210
|
i -= 2;
|
|
@@ -1232,7 +1232,7 @@ var environment = function(externalEnvironment, fileManagers) {
|
|
|
1232
1232
|
requiredFunctions = [],
|
|
1233
1233
|
functions = requiredFunctions.concat(optionalFunctions);
|
|
1234
1234
|
|
|
1235
|
-
for(var i = 0; i < functions.length; i++) {
|
|
1235
|
+
for (var i = 0; i < functions.length; i++) {
|
|
1236
1236
|
var propName = functions[i],
|
|
1237
1237
|
environmentFunc = externalEnvironment[propName];
|
|
1238
1238
|
if (environmentFunc) {
|
|
@@ -1256,7 +1256,7 @@ environment.prototype.getFileManager = function (filename, currentDirectory, opt
|
|
|
1256
1256
|
if (options.pluginManager) {
|
|
1257
1257
|
fileManagers = [].concat(fileManagers).concat(options.pluginManager.getFileManagers());
|
|
1258
1258
|
}
|
|
1259
|
-
for(var i = fileManagers.length - 1; i >= 0 ; i--) {
|
|
1259
|
+
for (var i = fileManagers.length - 1; i >= 0 ; i--) {
|
|
1260
1260
|
var fileManager = fileManagers[i];
|
|
1261
1261
|
if (fileManager[isSync ? "supportsSync" : "supports"](filename, currentDirectory, options, environment)) {
|
|
1262
1262
|
return fileManager;
|
|
@@ -1368,7 +1368,7 @@ function hsla(color) {
|
|
|
1368
1368
|
function number(n) {
|
|
1369
1369
|
if (n instanceof Dimension) {
|
|
1370
1370
|
return parseFloat(n.unit.is('%') ? n.value / 100 : n.value);
|
|
1371
|
-
} else if (typeof
|
|
1371
|
+
} else if (typeof n === 'number') {
|
|
1372
1372
|
return n;
|
|
1373
1373
|
} else {
|
|
1374
1374
|
throw {
|
|
@@ -1399,10 +1399,18 @@ colorFunctions = {
|
|
|
1399
1399
|
hsla: function (h, s, l, a) {
|
|
1400
1400
|
function hue(h) {
|
|
1401
1401
|
h = h < 0 ? h + 1 : (h > 1 ? h - 1 : h);
|
|
1402
|
-
if
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
else
|
|
1402
|
+
if (h * 6 < 1) {
|
|
1403
|
+
return m1 + (m2 - m1) * h * 6;
|
|
1404
|
+
}
|
|
1405
|
+
else if (h * 2 < 1) {
|
|
1406
|
+
return m2;
|
|
1407
|
+
}
|
|
1408
|
+
else if (h * 3 < 2) {
|
|
1409
|
+
return m1 + (m2 - m1) * (2 / 3 - h) * 6;
|
|
1410
|
+
}
|
|
1411
|
+
else {
|
|
1412
|
+
return m1;
|
|
1413
|
+
}
|
|
1406
1414
|
}
|
|
1407
1415
|
|
|
1408
1416
|
h = (number(h) % 360) / 360;
|
|
@@ -1843,7 +1851,7 @@ for (var f in mathFunctions) {
|
|
|
1843
1851
|
}
|
|
1844
1852
|
|
|
1845
1853
|
mathFunctions.round = function (n, f) {
|
|
1846
|
-
var fraction = typeof
|
|
1854
|
+
var fraction = typeof f === "undefined" ? 0 : f.value;
|
|
1847
1855
|
return _math(function(num) { return num.toFixed(fraction); }, null, n);
|
|
1848
1856
|
};
|
|
1849
1857
|
|
|
@@ -1866,7 +1874,7 @@ var minMax = function (isMin, args) {
|
|
|
1866
1874
|
for (i = 0; i < args.length; i++) {
|
|
1867
1875
|
current = args[i];
|
|
1868
1876
|
if (!(current instanceof Dimension)) {
|
|
1869
|
-
if(Array.isArray(args[i].value)) {
|
|
1877
|
+
if (Array.isArray(args[i].value)) {
|
|
1870
1878
|
Array.prototype.push.apply(args, Array.prototype.slice.call(args[i].value));
|
|
1871
1879
|
}
|
|
1872
1880
|
continue;
|
|
@@ -1877,7 +1885,7 @@ var minMax = function (isMin, args) {
|
|
|
1877
1885
|
unitClone = unit !== "" && unitClone === undefined ? current.unit.toString() : unitClone;
|
|
1878
1886
|
j = values[""] !== undefined && unit !== "" && unit === unitStatic ? values[""] : values[unit];
|
|
1879
1887
|
if (j === undefined) {
|
|
1880
|
-
if(unitStatic !== undefined && unit !== unitStatic) {
|
|
1888
|
+
if (unitStatic !== undefined && unit !== unitStatic) {
|
|
1881
1889
|
throw{ type: "Argument", message: "incompatible types" };
|
|
1882
1890
|
}
|
|
1883
1891
|
values[unit] = order.length;
|
|
@@ -2058,7 +2066,7 @@ var Keyword = require("../tree/keyword"),
|
|
|
2058
2066
|
functionRegistry = require("./function-registry");
|
|
2059
2067
|
|
|
2060
2068
|
var isa = function (n, Type) {
|
|
2061
|
-
|
|
2069
|
+
return (n instanceof Type) ? Keyword.True : Keyword.False;
|
|
2062
2070
|
},
|
|
2063
2071
|
isunit = function (n, unit) {
|
|
2064
2072
|
if (unit === undefined) {
|
|
@@ -2069,6 +2077,19 @@ var isa = function (n, Type) {
|
|
|
2069
2077
|
throw { type: "Argument", message: "Second argument to isunit should be a unit or a string." };
|
|
2070
2078
|
}
|
|
2071
2079
|
return (n instanceof Dimension) && n.unit.is(unit) ? Keyword.True : Keyword.False;
|
|
2080
|
+
},
|
|
2081
|
+
getItemsFromNode = function(node) {
|
|
2082
|
+
// handle non-array values as an array of length 1
|
|
2083
|
+
// return 'undefined' if index is invalid
|
|
2084
|
+
var items = Array.isArray(node.value) ?
|
|
2085
|
+
node.value : Array(node);
|
|
2086
|
+
|
|
2087
|
+
return items.filter(function(item) {
|
|
2088
|
+
if (item.type === "Comment") {
|
|
2089
|
+
return false;
|
|
2090
|
+
}
|
|
2091
|
+
return true;
|
|
2092
|
+
});
|
|
2072
2093
|
};
|
|
2073
2094
|
functionRegistry.addMultiple({
|
|
2074
2095
|
isruleset: function (n) {
|
|
@@ -2100,7 +2121,7 @@ functionRegistry.addMultiple({
|
|
|
2100
2121
|
},
|
|
2101
2122
|
isunit: isunit,
|
|
2102
2123
|
unit: function (val, unit) {
|
|
2103
|
-
if(!(val instanceof Dimension)) {
|
|
2124
|
+
if (!(val instanceof Dimension)) {
|
|
2104
2125
|
throw { type: "Argument",
|
|
2105
2126
|
message: "the first argument to unit must be a number" +
|
|
2106
2127
|
(val instanceof Operation ? ". Have you forgotten parenthesis?" : "") };
|
|
@@ -2121,14 +2142,11 @@ functionRegistry.addMultiple({
|
|
|
2121
2142
|
},
|
|
2122
2143
|
extract: function(values, index) {
|
|
2123
2144
|
index = index.value - 1; // (1-based index)
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
return Array.isArray(values.value) ?
|
|
2127
|
-
values.value[index] : Array(values)[index];
|
|
2145
|
+
|
|
2146
|
+
return getItemsFromNode(values)[index];
|
|
2128
2147
|
},
|
|
2129
2148
|
length: function(values) {
|
|
2130
|
-
|
|
2131
|
-
return new Dimension(n);
|
|
2149
|
+
return new Dimension(getItemsFromNode(values).length);
|
|
2132
2150
|
}
|
|
2133
2151
|
});
|
|
2134
2152
|
|
|
@@ -2176,12 +2194,12 @@ module.exports = function(environment) {
|
|
|
2176
2194
|
|
|
2177
2195
|
var importedEqualsRoot = fullPath === importManager.rootFilename;
|
|
2178
2196
|
if (importOptions.optional && e) {
|
|
2179
|
-
|
|
2197
|
+
callback(null, {rules:[]}, false, null);
|
|
2180
2198
|
}
|
|
2181
2199
|
else {
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2200
|
+
importManager.files[fullPath] = root;
|
|
2201
|
+
if (e && !importManager.error) { importManager.error = e; }
|
|
2202
|
+
callback(e, root, importedEqualsRoot, fullPath);
|
|
2185
2203
|
}
|
|
2186
2204
|
};
|
|
2187
2205
|
|
|
@@ -2216,7 +2234,7 @@ module.exports = function(environment) {
|
|
|
2216
2234
|
// - If path of imported file is '../mixins.less' and rootpath is 'less/',
|
|
2217
2235
|
// then rootpath should become 'less/../'
|
|
2218
2236
|
newFileInfo.currentDirectory = fileManager.getPath(resolvedFilename);
|
|
2219
|
-
if(newFileInfo.relativeUrls) {
|
|
2237
|
+
if (newFileInfo.relativeUrls) {
|
|
2220
2238
|
newFileInfo.rootpath = fileManager.join(
|
|
2221
2239
|
(importManager.context.rootpath || ""),
|
|
2222
2240
|
fileManager.pathDiff(newFileInfo.currentDirectory, newFileInfo.entryPath));
|
|
@@ -2265,7 +2283,7 @@ module.exports = function(environment, fileManagers) {
|
|
|
2265
2283
|
var SourceMapOutput, SourceMapBuilder, ParseTree, ImportManager, Environment;
|
|
2266
2284
|
|
|
2267
2285
|
var less = {
|
|
2268
|
-
version: [2,
|
|
2286
|
+
version: [2, 4, 0],
|
|
2269
2287
|
data: require('./data'),
|
|
2270
2288
|
tree: require('./tree'),
|
|
2271
2289
|
Environment: (Environment = require("./environment/environment")),
|
|
@@ -2311,7 +2329,7 @@ var LessError = module.exports = function LessError(e, importManager, currentFil
|
|
|
2311
2329
|
this.type = e.type || 'Syntax';
|
|
2312
2330
|
this.filename = filename;
|
|
2313
2331
|
this.index = e.index;
|
|
2314
|
-
this.line = typeof
|
|
2332
|
+
this.line = typeof line === 'number' ? line + 1 : null;
|
|
2315
2333
|
this.callLine = callLine + 1;
|
|
2316
2334
|
this.callExtract = lines[callLine];
|
|
2317
2335
|
this.column = col;
|
|
@@ -2353,7 +2371,7 @@ module.exports = {
|
|
|
2353
2371
|
this._listeners.push(listener);
|
|
2354
2372
|
},
|
|
2355
2373
|
removeListener: function(listener) {
|
|
2356
|
-
for(var i = 0; i < this._listeners.length; i++) {
|
|
2374
|
+
for (var i = 0; i < this._listeners.length; i++) {
|
|
2357
2375
|
if (this._listeners[i] === listener) {
|
|
2358
2376
|
this._listeners.splice(i, 1);
|
|
2359
2377
|
return;
|
|
@@ -2361,7 +2379,7 @@ module.exports = {
|
|
|
2361
2379
|
}
|
|
2362
2380
|
},
|
|
2363
2381
|
_fireEvent: function(type, msg) {
|
|
2364
|
-
for(var i = 0; i < this._listeners.length; i++) {
|
|
2382
|
+
for (var i = 0; i < this._listeners.length; i++) {
|
|
2365
2383
|
var logFunction = this._listeners[i][type];
|
|
2366
2384
|
if (logFunction) {
|
|
2367
2385
|
logFunction(msg);
|
|
@@ -2377,64 +2395,64 @@ var LessError = require('./less-error'),
|
|
|
2377
2395
|
logger = require("./logger");
|
|
2378
2396
|
|
|
2379
2397
|
module.exports = function(SourceMapBuilder) {
|
|
2380
|
-
var ParseTree = function(root, imports) {
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
};
|
|
2384
|
-
|
|
2385
|
-
ParseTree.prototype.toCSS = function(options) {
|
|
2386
|
-
var evaldRoot, result = {}, sourceMapBuilder;
|
|
2387
|
-
try {
|
|
2388
|
-
evaldRoot = transformTree(this.root, options);
|
|
2389
|
-
} catch (e) {
|
|
2390
|
-
throw new LessError(e, this.imports);
|
|
2391
|
-
}
|
|
2398
|
+
var ParseTree = function(root, imports) {
|
|
2399
|
+
this.root = root;
|
|
2400
|
+
this.imports = imports;
|
|
2401
|
+
};
|
|
2392
2402
|
|
|
2393
|
-
|
|
2394
|
-
var
|
|
2395
|
-
|
|
2396
|
-
|
|
2403
|
+
ParseTree.prototype.toCSS = function(options) {
|
|
2404
|
+
var evaldRoot, result = {}, sourceMapBuilder;
|
|
2405
|
+
try {
|
|
2406
|
+
evaldRoot = transformTree(this.root, options);
|
|
2407
|
+
} catch (e) {
|
|
2408
|
+
throw new LessError(e, this.imports);
|
|
2397
2409
|
}
|
|
2398
2410
|
|
|
2399
|
-
|
|
2400
|
-
compress
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2411
|
+
try {
|
|
2412
|
+
var compress = Boolean(options.compress);
|
|
2413
|
+
if (compress) {
|
|
2414
|
+
logger.warn("The compress option has been deprecated. We recommend you use a dedicated css minifier, for instance see less-plugin-clean-css.");
|
|
2415
|
+
}
|
|
2404
2416
|
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2417
|
+
var toCSSOptions = {
|
|
2418
|
+
compress: compress,
|
|
2419
|
+
dumpLineNumbers: options.dumpLineNumbers,
|
|
2420
|
+
strictUnits: Boolean(options.strictUnits),
|
|
2421
|
+
numPrecision: 8};
|
|
2422
|
+
|
|
2423
|
+
if (options.sourceMap) {
|
|
2424
|
+
sourceMapBuilder = new SourceMapBuilder(options.sourceMap);
|
|
2425
|
+
result.css = sourceMapBuilder.toCSS(evaldRoot, toCSSOptions, this.imports);
|
|
2426
|
+
} else {
|
|
2427
|
+
result.css = evaldRoot.toCSS(toCSSOptions);
|
|
2428
|
+
}
|
|
2429
|
+
} catch (e) {
|
|
2430
|
+
throw new LessError(e, this.imports);
|
|
2410
2431
|
}
|
|
2411
|
-
} catch (e) {
|
|
2412
|
-
throw new LessError(e, this.imports);
|
|
2413
|
-
}
|
|
2414
2432
|
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2433
|
+
if (options.pluginManager) {
|
|
2434
|
+
var postProcessors = options.pluginManager.getPostProcessors();
|
|
2435
|
+
for (var i = 0; i < postProcessors.length; i++) {
|
|
2436
|
+
result.css = postProcessors[i].process(result.css, { sourceMap: sourceMapBuilder, options: options, imports: this.imports });
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
if (options.sourceMap) {
|
|
2440
|
+
result.map = sourceMapBuilder.getExternalSourceMap();
|
|
2419
2441
|
}
|
|
2420
|
-
}
|
|
2421
|
-
if (options.sourceMap) {
|
|
2422
|
-
result.map = sourceMapBuilder.getExternalSourceMap();
|
|
2423
|
-
}
|
|
2424
2442
|
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2443
|
+
result.imports = [];
|
|
2444
|
+
for (var file in this.imports.files) {
|
|
2445
|
+
if (this.imports.files.hasOwnProperty(file) && file !== this.imports.rootFilename) {
|
|
2446
|
+
result.imports.push(file);
|
|
2447
|
+
}
|
|
2429
2448
|
}
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
return ParseTree;
|
|
2449
|
+
return result;
|
|
2450
|
+
};
|
|
2451
|
+
return ParseTree;
|
|
2434
2452
|
};
|
|
2435
2453
|
|
|
2436
2454
|
},{"./less-error":30,"./logger":31,"./transform-tree":41}],33:[function(require,module,exports){
|
|
2437
|
-
var PromiseConstructor
|
|
2455
|
+
var PromiseConstructor,
|
|
2438
2456
|
contexts = require("./contexts"),
|
|
2439
2457
|
Parser = require('./parser/parser'),
|
|
2440
2458
|
PluginManager = require('./plugin-manager');
|
|
@@ -2443,12 +2461,15 @@ module.exports = function(environment, ParseTree, ImportManager) {
|
|
|
2443
2461
|
var parse = function (input, options, callback) {
|
|
2444
2462
|
options = options || {};
|
|
2445
2463
|
|
|
2446
|
-
if (typeof
|
|
2464
|
+
if (typeof options === 'function') {
|
|
2447
2465
|
callback = options;
|
|
2448
2466
|
options = {};
|
|
2449
2467
|
}
|
|
2450
2468
|
|
|
2451
2469
|
if (!callback) {
|
|
2470
|
+
if (!PromiseConstructor) {
|
|
2471
|
+
PromiseConstructor = typeof Promise === 'undefined' ? require('promise') : Promise;
|
|
2472
|
+
}
|
|
2452
2473
|
var self = this;
|
|
2453
2474
|
return new PromiseConstructor(function (resolve, reject) {
|
|
2454
2475
|
parse.call(self, input, options, function(err, output) {
|
|
@@ -2690,7 +2711,7 @@ module.exports = function() {
|
|
|
2690
2711
|
//
|
|
2691
2712
|
skipWhitespace(length);
|
|
2692
2713
|
|
|
2693
|
-
if(typeof
|
|
2714
|
+
if (typeof match === 'string') {
|
|
2694
2715
|
return match;
|
|
2695
2716
|
} else {
|
|
2696
2717
|
return match.length === 1 ? match[0] : match;
|
|
@@ -2709,7 +2730,7 @@ module.exports = function() {
|
|
|
2709
2730
|
}
|
|
2710
2731
|
|
|
2711
2732
|
skipWhitespace(m[0].length);
|
|
2712
|
-
if(typeof m === "string") {
|
|
2733
|
+
if (typeof m === "string") {
|
|
2713
2734
|
return m;
|
|
2714
2735
|
}
|
|
2715
2736
|
|
|
@@ -2802,7 +2823,7 @@ module.exports = function() {
|
|
|
2802
2823
|
// Same as $(), but don't change the state of the parser,
|
|
2803
2824
|
// just return the match.
|
|
2804
2825
|
parserInput.peek = function(tok) {
|
|
2805
|
-
if (typeof
|
|
2826
|
+
if (typeof tok === 'string') {
|
|
2806
2827
|
return input.charAt(parserInput.i) === tok;
|
|
2807
2828
|
} else {
|
|
2808
2829
|
return tok.test(current);
|
|
@@ -2924,7 +2945,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
2924
2945
|
if (result) {
|
|
2925
2946
|
return result;
|
|
2926
2947
|
}
|
|
2927
|
-
error(msg || (typeof
|
|
2948
|
+
error(msg || (typeof arg === 'string' ? "expected '" + arg + "' got '" + parserInput.currentChar() + "'"
|
|
2928
2949
|
: "unexpected token"));
|
|
2929
2950
|
}
|
|
2930
2951
|
|
|
@@ -2969,17 +2990,26 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
2969
2990
|
// @param [additionalData] An optional map which can contains vars - a map (key, value) of variables to apply
|
|
2970
2991
|
//
|
|
2971
2992
|
parse: function (str, callback, additionalData) {
|
|
2972
|
-
var root, error = null, globalVars, modifyVars, preText = "";
|
|
2993
|
+
var root, error = null, globalVars, modifyVars, ignored, preText = "";
|
|
2973
2994
|
|
|
2974
2995
|
globalVars = (additionalData && additionalData.globalVars) ? Parser.serializeVars(additionalData.globalVars) + '\n' : '';
|
|
2975
2996
|
modifyVars = (additionalData && additionalData.modifyVars) ? '\n' + Parser.serializeVars(additionalData.modifyVars) : '';
|
|
2976
2997
|
|
|
2998
|
+
if (context.pluginManager) {
|
|
2999
|
+
var preProcessors = context.pluginManager.getPreProcessors();
|
|
3000
|
+
for (var i = 0; i < preProcessors.length; i++) {
|
|
3001
|
+
str = preProcessors[i].process(str, { context: context, imports: imports, fileInfo: fileInfo });
|
|
3002
|
+
}
|
|
3003
|
+
}
|
|
3004
|
+
|
|
2977
3005
|
if (globalVars || (additionalData && additionalData.banner)) {
|
|
2978
3006
|
preText = ((additionalData && additionalData.banner) ? additionalData.banner : "") + globalVars;
|
|
2979
|
-
|
|
3007
|
+
ignored = imports.contentsIgnoredChars;
|
|
3008
|
+
ignored[fileInfo.filename] = ignored[fileInfo.filename] || 0;
|
|
3009
|
+
ignored[fileInfo.filename] += preText.length;
|
|
2980
3010
|
}
|
|
2981
3011
|
|
|
2982
|
-
str = str.replace(/\r\n
|
|
3012
|
+
str = str.replace(/\r\n?/g, '\n');
|
|
2983
3013
|
// Remove potential UTF Byte Order Mark
|
|
2984
3014
|
str = preText + str.replace(/^\uFEFF/, '') + modifyVars;
|
|
2985
3015
|
imports.contents[fileInfo.filename] = str;
|
|
@@ -3110,7 +3140,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
3110
3140
|
|
|
3111
3141
|
while (true)
|
|
3112
3142
|
{
|
|
3113
|
-
while(true) {
|
|
3143
|
+
while (true) {
|
|
3114
3144
|
node = this.comment();
|
|
3115
3145
|
if (!node) { break; }
|
|
3116
3146
|
root.push(node);
|
|
@@ -3209,7 +3239,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
3209
3239
|
|
|
3210
3240
|
if (nameLC === 'alpha') {
|
|
3211
3241
|
alpha = parsers.alpha();
|
|
3212
|
-
if(alpha) {
|
|
3242
|
+
if (alpha) {
|
|
3213
3243
|
return alpha;
|
|
3214
3244
|
}
|
|
3215
3245
|
}
|
|
@@ -3424,8 +3454,14 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
3424
3454
|
elements = null;
|
|
3425
3455
|
while (! (option = parserInput.$re(/^(all)(?=\s*(\)|,))/))) {
|
|
3426
3456
|
e = this.element();
|
|
3427
|
-
if (!e) {
|
|
3428
|
-
|
|
3457
|
+
if (!e) {
|
|
3458
|
+
break;
|
|
3459
|
+
}
|
|
3460
|
+
if (elements) {
|
|
3461
|
+
elements.push(e);
|
|
3462
|
+
} else {
|
|
3463
|
+
elements = [ e ];
|
|
3464
|
+
}
|
|
3429
3465
|
}
|
|
3430
3466
|
|
|
3431
3467
|
option = option && option[1];
|
|
@@ -3433,9 +3469,12 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
3433
3469
|
error("Missing target selector for :extend().");
|
|
3434
3470
|
}
|
|
3435
3471
|
extend = new(tree.Extend)(new(tree.Selector)(elements), option, index);
|
|
3436
|
-
if (extendList) {
|
|
3437
|
-
|
|
3438
|
-
|
|
3472
|
+
if (extendList) {
|
|
3473
|
+
extendList.push(extend);
|
|
3474
|
+
} else {
|
|
3475
|
+
extendList = [ extend ];
|
|
3476
|
+
}
|
|
3477
|
+
} while (parserInput.$char(","));
|
|
3439
3478
|
|
|
3440
3479
|
expect(/^\)/);
|
|
3441
3480
|
|
|
@@ -3483,7 +3522,11 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
3483
3522
|
break;
|
|
3484
3523
|
}
|
|
3485
3524
|
elem = new(tree.Element)(c, e, elemIndex, fileInfo);
|
|
3486
|
-
if (elements) {
|
|
3525
|
+
if (elements) {
|
|
3526
|
+
elements.push(elem);
|
|
3527
|
+
} else {
|
|
3528
|
+
elements = [ elem ];
|
|
3529
|
+
}
|
|
3487
3530
|
c = parserInput.$char('>');
|
|
3488
3531
|
}
|
|
3489
3532
|
|
|
@@ -3824,11 +3867,19 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
3824
3867
|
} else if (condition) {
|
|
3825
3868
|
error("CSS guard can only be used at the end of selector");
|
|
3826
3869
|
} else if (extendList) {
|
|
3827
|
-
if (allExtends) {
|
|
3870
|
+
if (allExtends) {
|
|
3871
|
+
allExtends = allExtends.concat(extendList);
|
|
3872
|
+
} else {
|
|
3873
|
+
allExtends = extendList;
|
|
3874
|
+
}
|
|
3828
3875
|
} else {
|
|
3829
3876
|
if (allExtends) { error("Extend can only be used at the end of selector"); }
|
|
3830
3877
|
c = parserInput.currentChar();
|
|
3831
|
-
if (elements) {
|
|
3878
|
+
if (elements) {
|
|
3879
|
+
elements.push(e);
|
|
3880
|
+
} else {
|
|
3881
|
+
elements = [ e ];
|
|
3882
|
+
}
|
|
3832
3883
|
e = null;
|
|
3833
3884
|
}
|
|
3834
3885
|
if (c === '{' || c === '}' || c === ';' || c === ',' || c === ')') {
|
|
@@ -3903,7 +3954,11 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
3903
3954
|
if (!s) {
|
|
3904
3955
|
break;
|
|
3905
3956
|
}
|
|
3906
|
-
if (selectors) {
|
|
3957
|
+
if (selectors) {
|
|
3958
|
+
selectors.push(s);
|
|
3959
|
+
} else {
|
|
3960
|
+
selectors = [ s ];
|
|
3961
|
+
}
|
|
3907
3962
|
parserInput.commentStore.length = 0;
|
|
3908
3963
|
if (s.condition && selectors.length > 1) {
|
|
3909
3964
|
error("Guards are only currently allowed on a single selector.");
|
|
@@ -4040,11 +4095,11 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
4040
4095
|
case "css":
|
|
4041
4096
|
optionName = "less";
|
|
4042
4097
|
value = false;
|
|
4043
|
-
|
|
4098
|
+
break;
|
|
4044
4099
|
case "once":
|
|
4045
4100
|
optionName = "multiple";
|
|
4046
4101
|
value = false;
|
|
4047
|
-
|
|
4102
|
+
break;
|
|
4048
4103
|
}
|
|
4049
4104
|
options[optionName] = value;
|
|
4050
4105
|
if (! parserInput.$char(',')) { break; }
|
|
@@ -4255,7 +4310,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
4255
4310
|
expressions.push(e);
|
|
4256
4311
|
if (! parserInput.$char(',')) { break; }
|
|
4257
4312
|
}
|
|
4258
|
-
} while(e);
|
|
4313
|
+
} while (e);
|
|
4259
4314
|
|
|
4260
4315
|
if (expressions.length > 0) {
|
|
4261
4316
|
return new(tree.Value)(expressions);
|
|
@@ -4505,6 +4560,7 @@ module.exports = Parser;
|
|
|
4505
4560
|
var PluginManager = function(less) {
|
|
4506
4561
|
this.less = less;
|
|
4507
4562
|
this.visitors = [];
|
|
4563
|
+
this.preProcessors = [];
|
|
4508
4564
|
this.postProcessors = [];
|
|
4509
4565
|
this.installedPlugins = [];
|
|
4510
4566
|
this.fileManagers = [];
|
|
@@ -4515,7 +4571,7 @@ var PluginManager = function(less) {
|
|
|
4515
4571
|
*/
|
|
4516
4572
|
PluginManager.prototype.addPlugins = function(plugins) {
|
|
4517
4573
|
if (plugins) {
|
|
4518
|
-
for(var i = 0;i < plugins.length; i++) {
|
|
4574
|
+
for (var i = 0; i < plugins.length; i++) {
|
|
4519
4575
|
this.addPlugin(plugins[i]);
|
|
4520
4576
|
}
|
|
4521
4577
|
}
|
|
@@ -4536,6 +4592,20 @@ PluginManager.prototype.addPlugin = function(plugin) {
|
|
|
4536
4592
|
PluginManager.prototype.addVisitor = function(visitor) {
|
|
4537
4593
|
this.visitors.push(visitor);
|
|
4538
4594
|
};
|
|
4595
|
+
/**
|
|
4596
|
+
* Adds a pre processor object
|
|
4597
|
+
* @param {object} preProcessor
|
|
4598
|
+
* @param {number} priority - guidelines 1 = before import, 1000 = import, 2000 = after import
|
|
4599
|
+
*/
|
|
4600
|
+
PluginManager.prototype.addPreProcessor = function(preProcessor, priority) {
|
|
4601
|
+
var indexToInsertAt;
|
|
4602
|
+
for (indexToInsertAt = 0; indexToInsertAt < this.preProcessors.length; indexToInsertAt++) {
|
|
4603
|
+
if (this.preProcessors[indexToInsertAt].priority >= priority) {
|
|
4604
|
+
break;
|
|
4605
|
+
}
|
|
4606
|
+
}
|
|
4607
|
+
this.preProcessors.splice(indexToInsertAt, 0, {preProcessor: preProcessor, priority: priority});
|
|
4608
|
+
};
|
|
4539
4609
|
/**
|
|
4540
4610
|
* Adds a post processor object
|
|
4541
4611
|
* @param {object} postProcessor
|
|
@@ -4543,7 +4613,7 @@ PluginManager.prototype.addVisitor = function(visitor) {
|
|
|
4543
4613
|
*/
|
|
4544
4614
|
PluginManager.prototype.addPostProcessor = function(postProcessor, priority) {
|
|
4545
4615
|
var indexToInsertAt;
|
|
4546
|
-
for(indexToInsertAt = 0; indexToInsertAt < this.postProcessors.length; indexToInsertAt++) {
|
|
4616
|
+
for (indexToInsertAt = 0; indexToInsertAt < this.postProcessors.length; indexToInsertAt++) {
|
|
4547
4617
|
if (this.postProcessors[indexToInsertAt].priority >= priority) {
|
|
4548
4618
|
break;
|
|
4549
4619
|
}
|
|
@@ -4557,6 +4627,18 @@ PluginManager.prototype.addPostProcessor = function(postProcessor, priority) {
|
|
|
4557
4627
|
PluginManager.prototype.addFileManager = function(manager) {
|
|
4558
4628
|
this.fileManagers.push(manager);
|
|
4559
4629
|
};
|
|
4630
|
+
/**
|
|
4631
|
+
*
|
|
4632
|
+
* @returns {Array}
|
|
4633
|
+
* @private
|
|
4634
|
+
*/
|
|
4635
|
+
PluginManager.prototype.getPreProcessors = function() {
|
|
4636
|
+
var preProcessors = [];
|
|
4637
|
+
for (var i = 0; i < this.preProcessors.length; i++) {
|
|
4638
|
+
preProcessors.push(this.preProcessors[i].preProcessor);
|
|
4639
|
+
}
|
|
4640
|
+
return preProcessors;
|
|
4641
|
+
};
|
|
4560
4642
|
/**
|
|
4561
4643
|
*
|
|
4562
4644
|
* @returns {Array}
|
|
@@ -4564,7 +4646,7 @@ PluginManager.prototype.addFileManager = function(manager) {
|
|
|
4564
4646
|
*/
|
|
4565
4647
|
PluginManager.prototype.getPostProcessors = function() {
|
|
4566
4648
|
var postProcessors = [];
|
|
4567
|
-
for(var i = 0; i < this.postProcessors.length; i++) {
|
|
4649
|
+
for (var i = 0; i < this.postProcessors.length; i++) {
|
|
4568
4650
|
postProcessors.push(this.postProcessors[i].postProcessor);
|
|
4569
4651
|
}
|
|
4570
4652
|
return postProcessors;
|
|
@@ -4588,16 +4670,19 @@ PluginManager.prototype.getFileManagers = function() {
|
|
|
4588
4670
|
module.exports = PluginManager;
|
|
4589
4671
|
|
|
4590
4672
|
},{}],38:[function(require,module,exports){
|
|
4591
|
-
var PromiseConstructor
|
|
4673
|
+
var PromiseConstructor;
|
|
4592
4674
|
|
|
4593
4675
|
module.exports = function(environment, ParseTree, ImportManager) {
|
|
4594
4676
|
var render = function (input, options, callback) {
|
|
4595
|
-
if (typeof
|
|
4677
|
+
if (typeof options === 'function') {
|
|
4596
4678
|
callback = options;
|
|
4597
4679
|
options = {};
|
|
4598
4680
|
}
|
|
4599
4681
|
|
|
4600
4682
|
if (!callback) {
|
|
4683
|
+
if (!PromiseConstructor) {
|
|
4684
|
+
PromiseConstructor = typeof Promise === 'undefined' ? require('promise') : Promise;
|
|
4685
|
+
}
|
|
4601
4686
|
var self = this;
|
|
4602
4687
|
return new PromiseConstructor(function (resolve, reject) {
|
|
4603
4688
|
render.call(self, input, options, function(err, output) {
|
|
@@ -4660,8 +4745,12 @@ module.exports = function (SourceMapOutput, environment) {
|
|
|
4660
4745
|
};
|
|
4661
4746
|
|
|
4662
4747
|
SourceMapBuilder.prototype.getCSSAppendage = function() {
|
|
4748
|
+
|
|
4663
4749
|
var sourceMapURL = this.sourceMapURL;
|
|
4664
4750
|
if (this.options.sourceMapFileInline) {
|
|
4751
|
+
if (this.sourceMap === undefined) {
|
|
4752
|
+
return "";
|
|
4753
|
+
}
|
|
4665
4754
|
sourceMapURL = "data:application/json;base64," + environment.encodeBase64(this.sourceMap);
|
|
4666
4755
|
}
|
|
4667
4756
|
|
|
@@ -4731,7 +4820,7 @@ module.exports = function (environment) {
|
|
|
4731
4820
|
if (this._sourceMapBasepath && filename.indexOf(this._sourceMapBasepath) === 0) {
|
|
4732
4821
|
filename = filename.substring(this._sourceMapBasepath.length);
|
|
4733
4822
|
if (filename.charAt(0) === '\\' || filename.charAt(0) === '/') {
|
|
4734
|
-
|
|
4823
|
+
filename = filename.substring(1);
|
|
4735
4824
|
}
|
|
4736
4825
|
}
|
|
4737
4826
|
return (this._sourceMapRootpath || "") + filename;
|
|
@@ -4775,7 +4864,7 @@ module.exports = function (environment) {
|
|
|
4775
4864
|
original: { line: sourceLines.length, column: sourceColumns.length},
|
|
4776
4865
|
source: this.normalizeFilename(fileInfo.filename)});
|
|
4777
4866
|
} else {
|
|
4778
|
-
for(i = 0; i < lines.length; i++) {
|
|
4867
|
+
for (i = 0; i < lines.length; i++) {
|
|
4779
4868
|
this._sourceMapGenerator.addMapping({ generated: { line: this._lineNumber + i + 1, column: i === 0 ? this._column : 0},
|
|
4780
4869
|
original: { line: sourceLines.length + i, column: i === 0 ? sourceColumns.length : 0},
|
|
4781
4870
|
source: this.normalizeFilename(fileInfo.filename)});
|
|
@@ -4801,7 +4890,7 @@ module.exports = function (environment) {
|
|
|
4801
4890
|
this._sourceMapGenerator = new this._sourceMapGeneratorConstructor({ file: this._outputFilename, sourceRoot: null });
|
|
4802
4891
|
|
|
4803
4892
|
if (this._outputSourceFiles) {
|
|
4804
|
-
for(var filename in this._contentsMap) {
|
|
4893
|
+
for (var filename in this._contentsMap) {
|
|
4805
4894
|
if (this._contentsMap.hasOwnProperty(filename))
|
|
4806
4895
|
{
|
|
4807
4896
|
var source = this._contentsMap[filename];
|
|
@@ -4859,7 +4948,7 @@ module.exports = function(root, options) {
|
|
|
4859
4948
|
// ])
|
|
4860
4949
|
// )
|
|
4861
4950
|
//
|
|
4862
|
-
if (typeof
|
|
4951
|
+
if (typeof variables === 'object' && !Array.isArray(variables)) {
|
|
4863
4952
|
variables = Object.keys(variables).map(function (k) {
|
|
4864
4953
|
var value = variables[k];
|
|
4865
4954
|
|
|
@@ -4883,7 +4972,7 @@ module.exports = function(root, options) {
|
|
|
4883
4972
|
|
|
4884
4973
|
if (options.pluginManager) {
|
|
4885
4974
|
var pluginVisitors = options.pluginManager.getVisitors();
|
|
4886
|
-
for(i = 0; i < pluginVisitors.length; i++) {
|
|
4975
|
+
for (i = 0; i < pluginVisitors.length; i++) {
|
|
4887
4976
|
var pluginVisitor = pluginVisitors[i];
|
|
4888
4977
|
if (pluginVisitor.isPreEvalVisitor) {
|
|
4889
4978
|
preEvalVisitors.push(pluginVisitor);
|
|
@@ -4897,13 +4986,13 @@ module.exports = function(root, options) {
|
|
|
4897
4986
|
}
|
|
4898
4987
|
}
|
|
4899
4988
|
|
|
4900
|
-
for(i = 0; i < preEvalVisitors.length; i++) {
|
|
4989
|
+
for (i = 0; i < preEvalVisitors.length; i++) {
|
|
4901
4990
|
preEvalVisitors[i].run(root);
|
|
4902
4991
|
}
|
|
4903
4992
|
|
|
4904
4993
|
evaldRoot = root.eval(evalEnv);
|
|
4905
4994
|
|
|
4906
|
-
for(i = 0; i < visitors.length; i++) {
|
|
4995
|
+
for (i = 0; i < visitors.length; i++) {
|
|
4907
4996
|
visitors[i].run(evaldRoot);
|
|
4908
4997
|
}
|
|
4909
4998
|
|
|
@@ -4948,7 +5037,7 @@ var Anonymous = function (value, index, currentFileInfo, mapLines, rulesetLike)
|
|
|
4948
5037
|
this.index = index;
|
|
4949
5038
|
this.mapLines = mapLines;
|
|
4950
5039
|
this.currentFileInfo = currentFileInfo;
|
|
4951
|
-
this.rulesetLike = (typeof rulesetLike === 'undefined')? false : rulesetLike;
|
|
5040
|
+
this.rulesetLike = (typeof rulesetLike === 'undefined') ? false : rulesetLike;
|
|
4952
5041
|
};
|
|
4953
5042
|
Anonymous.prototype = new Node();
|
|
4954
5043
|
Anonymous.prototype.type = "Anonymous";
|
|
@@ -5077,7 +5166,7 @@ Call.prototype.eval = function (context) {
|
|
|
5077
5166
|
Call.prototype.genCSS = function (context, output) {
|
|
5078
5167
|
output.add(this.name + "(", this.currentFileInfo, this.index);
|
|
5079
5168
|
|
|
5080
|
-
for(var i = 0; i < this.args.length; i++) {
|
|
5169
|
+
for (var i = 0; i < this.args.length; i++) {
|
|
5081
5170
|
this.args[i].genCSS(context, output);
|
|
5082
5171
|
if (i + 1 < this.args.length) {
|
|
5083
5172
|
output.add(", ");
|
|
@@ -5113,7 +5202,7 @@ var Color = function (rgb, a) {
|
|
|
5113
5202
|
return parseInt(c + c, 16);
|
|
5114
5203
|
});
|
|
5115
5204
|
}
|
|
5116
|
-
this.alpha = typeof
|
|
5205
|
+
this.alpha = typeof a === 'number' ? a : 1;
|
|
5117
5206
|
};
|
|
5118
5207
|
|
|
5119
5208
|
Color.prototype = new Node();
|
|
@@ -5240,7 +5329,7 @@ Color.prototype.toHSV = function () {
|
|
|
5240
5329
|
if (max === min) {
|
|
5241
5330
|
h = 0;
|
|
5242
5331
|
} else {
|
|
5243
|
-
switch(max){
|
|
5332
|
+
switch(max) {
|
|
5244
5333
|
case r: h = (g - b) / d + (g < b ? 6 : 0); break;
|
|
5245
5334
|
case g: h = (b - r) / d + 2; break;
|
|
5246
5335
|
case b: h = (r - g) / d + 4; break;
|
|
@@ -5354,10 +5443,14 @@ Condition.prototype.eval = function (context) {
|
|
|
5354
5443
|
case 'or': return a || b;
|
|
5355
5444
|
default:
|
|
5356
5445
|
switch (Node.compare(a, b)) {
|
|
5357
|
-
case -1:
|
|
5358
|
-
|
|
5359
|
-
case
|
|
5360
|
-
|
|
5446
|
+
case -1:
|
|
5447
|
+
return op === '<' || op === '=<' || op === '<=';
|
|
5448
|
+
case 0:
|
|
5449
|
+
return op === '=' || op === '>=' || op === '=<' || op === '<=';
|
|
5450
|
+
case 1:
|
|
5451
|
+
return op === '>' || op === '>=';
|
|
5452
|
+
default:
|
|
5453
|
+
return false;
|
|
5361
5454
|
}
|
|
5362
5455
|
}
|
|
5363
5456
|
})(this.op, this.lvalue.eval(context), this.rvalue.eval(context));
|
|
@@ -5502,9 +5595,9 @@ Dimension.prototype.operate = function (context, op, other) {
|
|
|
5502
5595
|
} else {
|
|
5503
5596
|
other = other.convertTo(this.unit.usedUnits());
|
|
5504
5597
|
|
|
5505
|
-
if(context.strictUnits && other.unit.toString() !== unit.toString()) {
|
|
5506
|
-
|
|
5507
|
-
|
|
5598
|
+
if (context.strictUnits && other.unit.toString() !== unit.toString()) {
|
|
5599
|
+
throw new Error("Incompatible units. Change the units or use the unit function. Bad units: '" + unit.toString() +
|
|
5600
|
+
"' and '" + other.unit.toString() + "'.");
|
|
5508
5601
|
}
|
|
5509
5602
|
|
|
5510
5603
|
value = this._operate(context, op, this.value, other.value);
|
|
@@ -5548,7 +5641,7 @@ Dimension.prototype.convertTo = function (conversions) {
|
|
|
5548
5641
|
i, groupName, group, targetUnit, derivedConversions = {}, applyUnit;
|
|
5549
5642
|
|
|
5550
5643
|
if (typeof conversions === 'string') {
|
|
5551
|
-
for(i in unitConversions) {
|
|
5644
|
+
for (i in unitConversions) {
|
|
5552
5645
|
if (unitConversions[i].hasOwnProperty(conversions)) {
|
|
5553
5646
|
derivedConversions = {};
|
|
5554
5647
|
derivedConversions[i] = conversions;
|
|
@@ -5720,7 +5813,7 @@ var Element = function (combinator, value, index, currentFileInfo) {
|
|
|
5720
5813
|
this.combinator = combinator instanceof Combinator ?
|
|
5721
5814
|
combinator : new Combinator(combinator);
|
|
5722
5815
|
|
|
5723
|
-
if (typeof
|
|
5816
|
+
if (typeof value === 'string') {
|
|
5724
5817
|
this.value = value.trim();
|
|
5725
5818
|
} else if (value) {
|
|
5726
5819
|
this.value = value;
|
|
@@ -5810,7 +5903,7 @@ Expression.prototype.eval = function (context) {
|
|
|
5810
5903
|
return returnValue;
|
|
5811
5904
|
};
|
|
5812
5905
|
Expression.prototype.genCSS = function (context, output) {
|
|
5813
|
-
for(var i = 0; i < this.value.length; i++) {
|
|
5906
|
+
for (var i = 0; i < this.value.length; i++) {
|
|
5814
5907
|
this.value[i].genCSS(context, output);
|
|
5815
5908
|
if (i + 1 < this.value.length) {
|
|
5816
5909
|
output.add(" ");
|
|
@@ -5838,11 +5931,11 @@ var Extend = function Extend(selector, option, index) {
|
|
|
5838
5931
|
case "all":
|
|
5839
5932
|
this.allowBefore = true;
|
|
5840
5933
|
this.allowAfter = true;
|
|
5841
|
-
|
|
5934
|
+
break;
|
|
5842
5935
|
default:
|
|
5843
5936
|
this.allowBefore = false;
|
|
5844
5937
|
this.allowAfter = false;
|
|
5845
|
-
|
|
5938
|
+
break;
|
|
5846
5939
|
}
|
|
5847
5940
|
};
|
|
5848
5941
|
Extend.next_id = 0;
|
|
@@ -5863,7 +5956,7 @@ Extend.prototype.findSelfSelectors = function (selectors) {
|
|
|
5863
5956
|
i,
|
|
5864
5957
|
selectorElements;
|
|
5865
5958
|
|
|
5866
|
-
for(i = 0; i < selectors.length; i++) {
|
|
5959
|
+
for (i = 0; i < selectors.length; i++) {
|
|
5867
5960
|
selectorElements = selectors[i].elements;
|
|
5868
5961
|
// duplicate the logic in genCSS function inside the selector node.
|
|
5869
5962
|
// future TODO - move both logics into the selector joiner visitor
|
|
@@ -6079,9 +6172,9 @@ JavaScript.prototype.type = "JavaScript";
|
|
|
6079
6172
|
JavaScript.prototype.eval = function(context) {
|
|
6080
6173
|
var result = this.evaluateJavaScript(this.expression, context);
|
|
6081
6174
|
|
|
6082
|
-
if (typeof
|
|
6175
|
+
if (typeof result === 'number') {
|
|
6083
6176
|
return new Dimension(result);
|
|
6084
|
-
} else if (typeof
|
|
6177
|
+
} else if (typeof result === 'string') {
|
|
6085
6178
|
return new Quoted('"' + result + '"', result, this.escaped, this.index);
|
|
6086
6179
|
} else if (Array.isArray(result)) {
|
|
6087
6180
|
return new Anonymous(result.join(', '));
|
|
@@ -6213,7 +6306,7 @@ Media.prototype.eval = function (context) {
|
|
|
6213
6306
|
}
|
|
6214
6307
|
|
|
6215
6308
|
var media = new Media(null, [], this.index, this.currentFileInfo);
|
|
6216
|
-
if(this.debugInfo) {
|
|
6309
|
+
if (this.debugInfo) {
|
|
6217
6310
|
this.rules[0].debugInfo = this.debugInfo;
|
|
6218
6311
|
media.debugInfo = this.debugInfo;
|
|
6219
6312
|
}
|
|
@@ -6301,7 +6394,7 @@ Media.prototype.evalNested = function (context) {
|
|
|
6301
6394
|
return fragment.toCSS ? fragment : new Anonymous(fragment);
|
|
6302
6395
|
});
|
|
6303
6396
|
|
|
6304
|
-
for(i = path.length - 1; i > 0; i--) {
|
|
6397
|
+
for (i = path.length - 1; i > 0; i--) {
|
|
6305
6398
|
path.splice(i, 0, new Anonymous("and"));
|
|
6306
6399
|
}
|
|
6307
6400
|
|
|
@@ -6312,26 +6405,26 @@ Media.prototype.evalNested = function (context) {
|
|
|
6312
6405
|
return new Ruleset([], []);
|
|
6313
6406
|
};
|
|
6314
6407
|
Media.prototype.permute = function (arr) {
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6408
|
+
if (arr.length === 0) {
|
|
6409
|
+
return [];
|
|
6410
|
+
} else if (arr.length === 1) {
|
|
6411
|
+
return arr[0];
|
|
6412
|
+
} else {
|
|
6413
|
+
var result = [];
|
|
6414
|
+
var rest = this.permute(arr.slice(1));
|
|
6415
|
+
for (var i = 0; i < rest.length; i++) {
|
|
6416
|
+
for (var j = 0; j < arr[0].length; j++) {
|
|
6417
|
+
result.push([arr[0][j]].concat(rest[i]));
|
|
6418
|
+
}
|
|
6419
|
+
}
|
|
6420
|
+
return result;
|
|
6421
|
+
}
|
|
6329
6422
|
};
|
|
6330
6423
|
Media.prototype.bubbleSelectors = function (selectors) {
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6424
|
+
if (!selectors) {
|
|
6425
|
+
return;
|
|
6426
|
+
}
|
|
6427
|
+
this.rules = [new Ruleset(selectors.slice(0), [this.rules[0]])];
|
|
6335
6428
|
};
|
|
6336
6429
|
module.exports = Media;
|
|
6337
6430
|
|
|
@@ -6369,7 +6462,7 @@ MixinCall.prototype.eval = function (context) {
|
|
|
6369
6462
|
for (f = 0; f < 2; f++) {
|
|
6370
6463
|
conditionResult[f] = true;
|
|
6371
6464
|
defaultFunc.value(f);
|
|
6372
|
-
for(p = 0; p < mixinPath.length && conditionResult[f]; p++) {
|
|
6465
|
+
for (p = 0; p < mixinPath.length && conditionResult[f]; p++) {
|
|
6373
6466
|
namespace = mixinPath[p];
|
|
6374
6467
|
if (namespace.matchCondition) {
|
|
6375
6468
|
conditionResult[f] = conditionResult[f] && namespace.matchCondition(null, context);
|
|
@@ -6409,7 +6502,7 @@ MixinCall.prototype.eval = function (context) {
|
|
|
6409
6502
|
mixin = mixins[m].rule;
|
|
6410
6503
|
mixinPath = mixins[m].path;
|
|
6411
6504
|
isRecursive = false;
|
|
6412
|
-
for(f = 0; f < context.frames.length; f++) {
|
|
6505
|
+
for (f = 0; f < context.frames.length; f++) {
|
|
6413
6506
|
if ((!(mixin instanceof MixinDefinition)) && mixin === (context.frames[f].originalRuleset || context.frames[f])) {
|
|
6414
6507
|
isRecursive = true;
|
|
6415
6508
|
break;
|
|
@@ -6524,8 +6617,12 @@ var Definition = function (name, params, rules, condition, variadic, frames) {
|
|
|
6524
6617
|
this.rules = rules;
|
|
6525
6618
|
this._lookups = {};
|
|
6526
6619
|
this.required = params.reduce(function (count, p) {
|
|
6527
|
-
if (!p.name || (p.name && !p.value)) {
|
|
6528
|
-
|
|
6620
|
+
if (!p.name || (p.name && !p.value)) {
|
|
6621
|
+
return count + 1;
|
|
6622
|
+
}
|
|
6623
|
+
else {
|
|
6624
|
+
return count;
|
|
6625
|
+
}
|
|
6529
6626
|
}, 0);
|
|
6530
6627
|
this.frames = frames;
|
|
6531
6628
|
};
|
|
@@ -6554,11 +6651,11 @@ Definition.prototype.evalParams = function (context, mixinEnv, args, evaldArgume
|
|
|
6554
6651
|
args = args.slice(0);
|
|
6555
6652
|
argsLength = args.length;
|
|
6556
6653
|
|
|
6557
|
-
for(i = 0; i < argsLength; i++) {
|
|
6654
|
+
for (i = 0; i < argsLength; i++) {
|
|
6558
6655
|
arg = args[i];
|
|
6559
6656
|
if (name = (arg && arg.name)) {
|
|
6560
6657
|
isNamedFound = false;
|
|
6561
|
-
for(j = 0; j < params.length; j++) {
|
|
6658
|
+
for (j = 0; j < params.length; j++) {
|
|
6562
6659
|
if (!evaldArguments[j] && name === params[j].name) {
|
|
6563
6660
|
evaldArguments[j] = arg.value.eval(context);
|
|
6564
6661
|
frame.prependRule(new Rule(name, arg.value.eval(context)));
|
|
@@ -6617,6 +6714,17 @@ Definition.prototype.evalParams = function (context, mixinEnv, args, evaldArgume
|
|
|
6617
6714
|
|
|
6618
6715
|
return frame;
|
|
6619
6716
|
};
|
|
6717
|
+
Definition.prototype.makeImportant = function() {
|
|
6718
|
+
var rules = !this.rules ? this.rules : this.rules.map(function (r) {
|
|
6719
|
+
if (r.makeImportant) {
|
|
6720
|
+
return r.makeImportant(true);
|
|
6721
|
+
} else {
|
|
6722
|
+
return r;
|
|
6723
|
+
}
|
|
6724
|
+
});
|
|
6725
|
+
var result = new Definition (this.name, this.params, rules, this.condition, this.variadic, this.frames);
|
|
6726
|
+
return result;
|
|
6727
|
+
};
|
|
6620
6728
|
Definition.prototype.eval = function (context) {
|
|
6621
6729
|
return new Definition(this.name, this.params, this.rules, this.condition, this.variadic, this.frames || context.frames.slice(0));
|
|
6622
6730
|
};
|
|
@@ -6634,7 +6742,7 @@ Definition.prototype.evalCall = function (context, args, important) {
|
|
|
6634
6742
|
ruleset.originalRuleset = this;
|
|
6635
6743
|
ruleset = ruleset.eval(new contexts.Eval(context, [this, frame].concat(mixinFrames)));
|
|
6636
6744
|
if (important) {
|
|
6637
|
-
ruleset =
|
|
6745
|
+
ruleset = ruleset.makeImportant();
|
|
6638
6746
|
}
|
|
6639
6747
|
return ruleset;
|
|
6640
6748
|
};
|
|
@@ -6653,10 +6761,16 @@ Definition.prototype.matchArgs = function (args, context) {
|
|
|
6653
6761
|
var argsLength = (args && args.length) || 0, len;
|
|
6654
6762
|
|
|
6655
6763
|
if (! this.variadic) {
|
|
6656
|
-
if (argsLength < this.required)
|
|
6657
|
-
|
|
6764
|
+
if (argsLength < this.required) {
|
|
6765
|
+
return false;
|
|
6766
|
+
}
|
|
6767
|
+
if (argsLength > this.params.length) {
|
|
6768
|
+
return false;
|
|
6769
|
+
}
|
|
6658
6770
|
} else {
|
|
6659
|
-
if (argsLength < (this.required - 1))
|
|
6771
|
+
if (argsLength < (this.required - 1)) {
|
|
6772
|
+
return false;
|
|
6773
|
+
}
|
|
6660
6774
|
}
|
|
6661
6775
|
|
|
6662
6776
|
len = Math.min(argsLength, this.arity);
|
|
@@ -6876,9 +6990,9 @@ Quoted.prototype.eval = function (context) {
|
|
|
6876
6990
|
function iterativeReplace(value, regexp, replacementFnc) {
|
|
6877
6991
|
var evaluatedValue = value;
|
|
6878
6992
|
do {
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
} while
|
|
6993
|
+
value = evaluatedValue;
|
|
6994
|
+
evaluatedValue = value.replace(regexp, replacementFnc);
|
|
6995
|
+
} while (value !== evaluatedValue);
|
|
6882
6996
|
return evaluatedValue;
|
|
6883
6997
|
}
|
|
6884
6998
|
value = iterativeReplace(value, /`([^`]+)`/g, javascriptReplacement);
|
|
@@ -6942,7 +7056,7 @@ Rule.prototype.eval = function (context) {
|
|
|
6942
7056
|
// things faster (~10% for benchmark.less):
|
|
6943
7057
|
name = (name.length === 1) && (name[0] instanceof Keyword) ?
|
|
6944
7058
|
name[0].value : evalName(context, name);
|
|
6945
|
-
|
|
7059
|
+
variable = false; // never treat expanded interpolation as new variable name
|
|
6946
7060
|
}
|
|
6947
7061
|
if (name === "font" && !context.strictMath) {
|
|
6948
7062
|
strictMathBypass = true;
|
|
@@ -7068,7 +7182,7 @@ Ruleset.prototype.eval = function (context) {
|
|
|
7068
7182
|
ruleset.firstRoot = this.firstRoot;
|
|
7069
7183
|
ruleset.allowImports = this.allowImports;
|
|
7070
7184
|
|
|
7071
|
-
if(this.debugInfo) {
|
|
7185
|
+
if (this.debugInfo) {
|
|
7072
7186
|
ruleset.debugInfo = this.debugInfo;
|
|
7073
7187
|
}
|
|
7074
7188
|
|
|
@@ -7153,7 +7267,7 @@ Ruleset.prototype.eval = function (context) {
|
|
|
7153
7267
|
if (rule.selectors[0].isJustParentSelector()) {
|
|
7154
7268
|
rsRules.splice(i--, 1);
|
|
7155
7269
|
|
|
7156
|
-
for(var j = 0; j < rule.rules.length; j++) {
|
|
7270
|
+
for (var j = 0; j < rule.rules.length; j++) {
|
|
7157
7271
|
subRule = rule.rules[j];
|
|
7158
7272
|
if (!(subRule instanceof Rule) || !subRule.variable) {
|
|
7159
7273
|
rsRules.splice(++i, 0, subRule);
|
|
@@ -7193,15 +7307,17 @@ Ruleset.prototype.evalImports = function(context) {
|
|
|
7193
7307
|
}
|
|
7194
7308
|
};
|
|
7195
7309
|
Ruleset.prototype.makeImportant = function() {
|
|
7196
|
-
|
|
7310
|
+
var result = new Ruleset(this.selectors, this.rules.map(function (r) {
|
|
7197
7311
|
if (r.makeImportant) {
|
|
7198
7312
|
return r.makeImportant();
|
|
7199
7313
|
} else {
|
|
7200
7314
|
return r;
|
|
7201
7315
|
}
|
|
7202
|
-
});
|
|
7203
|
-
|
|
7204
|
-
|
|
7316
|
+
}), this.strictImports);
|
|
7317
|
+
|
|
7318
|
+
return result;
|
|
7319
|
+
};
|
|
7320
|
+
Ruleset.prototype.matchArgs = function (args) {
|
|
7205
7321
|
return !args || args.length === 0;
|
|
7206
7322
|
};
|
|
7207
7323
|
// lets you call a css selector with a guard
|
|
@@ -7234,7 +7350,7 @@ Ruleset.prototype.variables = function () {
|
|
|
7234
7350
|
// guard against root being a string (in the case of inlined less)
|
|
7235
7351
|
if (r.type === "Import" && r.root && r.root.variables) {
|
|
7236
7352
|
var vars = r.root.variables();
|
|
7237
|
-
for(var name in vars) {
|
|
7353
|
+
for (var name in vars) {
|
|
7238
7354
|
if (vars.hasOwnProperty(name)) {
|
|
7239
7355
|
hash[name] = vars[name];
|
|
7240
7356
|
}
|
|
@@ -7265,7 +7381,11 @@ Ruleset.prototype.rulesets = function () {
|
|
|
7265
7381
|
};
|
|
7266
7382
|
Ruleset.prototype.prependRule = function (rule) {
|
|
7267
7383
|
var rules = this.rules;
|
|
7268
|
-
if (rules) {
|
|
7384
|
+
if (rules) {
|
|
7385
|
+
rules.unshift(rule);
|
|
7386
|
+
} else {
|
|
7387
|
+
this.rules = [ rule ];
|
|
7388
|
+
}
|
|
7269
7389
|
};
|
|
7270
7390
|
Ruleset.prototype.find = function (selector, self, filter) {
|
|
7271
7391
|
self = self || this;
|
|
@@ -7280,13 +7400,13 @@ Ruleset.prototype.find = function (selector, self, filter) {
|
|
|
7280
7400
|
match = selector.match(rule.selectors[j]);
|
|
7281
7401
|
if (match) {
|
|
7282
7402
|
if (selector.elements.length > match) {
|
|
7283
|
-
|
|
7284
|
-
|
|
7285
|
-
|
|
7286
|
-
|
|
7403
|
+
if (!filter || filter(rule)) {
|
|
7404
|
+
foundMixins = rule.find(new Selector(selector.elements.slice(match)), self, filter);
|
|
7405
|
+
for (var i = 0; i < foundMixins.length; ++i) {
|
|
7406
|
+
foundMixins[i].path.push(rule);
|
|
7407
|
+
}
|
|
7408
|
+
Array.prototype.push.apply(rules, foundMixins);
|
|
7287
7409
|
}
|
|
7288
|
-
Array.prototype.push.apply(rules, foundMixins);
|
|
7289
|
-
}
|
|
7290
7410
|
} else {
|
|
7291
7411
|
rules.push({ rule: rule, path: []});
|
|
7292
7412
|
}
|
|
@@ -7319,19 +7439,17 @@ Ruleset.prototype.genCSS = function (context, output) {
|
|
|
7319
7439
|
sep;
|
|
7320
7440
|
|
|
7321
7441
|
function isRulesetLikeNode(rule, root) {
|
|
7322
|
-
|
|
7323
|
-
|
|
7324
|
-
|
|
7325
|
-
|
|
7326
|
-
|
|
7327
|
-
|
|
7328
|
-
|
|
7329
|
-
|
|
7330
|
-
return rule.isRulesetLike(root);
|
|
7331
|
-
}
|
|
7442
|
+
// if it has nested rules, then it should be treated like a ruleset
|
|
7443
|
+
// medias and comments do not have nested rules, but should be treated like rulesets anyway
|
|
7444
|
+
// some directives and anonymous nodes are ruleset like, others are not
|
|
7445
|
+
if (typeof rule.isRulesetLike === "boolean") {
|
|
7446
|
+
return rule.isRulesetLike;
|
|
7447
|
+
} else if (typeof rule.isRulesetLike === "function") {
|
|
7448
|
+
return rule.isRulesetLike(root);
|
|
7449
|
+
}
|
|
7332
7450
|
|
|
7333
|
-
|
|
7334
|
-
|
|
7451
|
+
//anything else is assumed to be a rule
|
|
7452
|
+
return false;
|
|
7335
7453
|
}
|
|
7336
7454
|
|
|
7337
7455
|
for (i = 0; i < this.rules.length; i++) {
|
|
@@ -7508,7 +7626,7 @@ Ruleset.prototype.joinSelector = function (paths, context, selector) {
|
|
|
7508
7626
|
// }
|
|
7509
7627
|
// == [[.a] [.c]] [[.b] [.c]]
|
|
7510
7628
|
//
|
|
7511
|
-
var i, j, k, currentElements, newSelectors, selectorsMultiplied, sel, el, hadParentSelector = false;
|
|
7629
|
+
var i, j, k, currentElements, newSelectors, selectorsMultiplied, sel, el, hadParentSelector = false, length, lastSelector;
|
|
7512
7630
|
function findNestedSelector(element) {
|
|
7513
7631
|
var maybeSelector;
|
|
7514
7632
|
if (element.value.type !== 'Paren') {
|
|
@@ -7602,8 +7720,11 @@ Ruleset.prototype.joinSelector = function (paths, context, selector) {
|
|
|
7602
7720
|
mergeElementsOnToSelectors(currentElements, newSelectors);
|
|
7603
7721
|
|
|
7604
7722
|
for (i = 0; i < newSelectors.length; i++) {
|
|
7605
|
-
|
|
7723
|
+
length = newSelectors[i].length;
|
|
7724
|
+
if (length > 0) {
|
|
7606
7725
|
paths.push(newSelectors[i]);
|
|
7726
|
+
lastSelector = newSelectors[i][length - 1];
|
|
7727
|
+
newSelectors[i][length - 1] = lastSelector.createDerived(lastSelector.elements, inSelector.extendList);
|
|
7607
7728
|
}
|
|
7608
7729
|
}
|
|
7609
7730
|
|
|
@@ -7810,7 +7931,7 @@ Selector.prototype.genCSS = function (context, output) {
|
|
|
7810
7931
|
}
|
|
7811
7932
|
if (!this._css) {
|
|
7812
7933
|
//TODO caching? speed comparison?
|
|
7813
|
-
for(i = 0; i < this.elements.length; i++) {
|
|
7934
|
+
for (i = 0; i < this.elements.length; i++) {
|
|
7814
7935
|
element = this.elements[i];
|
|
7815
7936
|
element.genCSS(context, output);
|
|
7816
7937
|
}
|
|
@@ -7864,6 +7985,8 @@ Unit.prototype.genCSS = function (context, output) {
|
|
|
7864
7985
|
output.add(this.numerator[0]); // the ideal situation
|
|
7865
7986
|
} else if (!strictUnits && this.backupUnit) {
|
|
7866
7987
|
output.add(this.backupUnit);
|
|
7988
|
+
} else if (!strictUnits && this.denominator.length) {
|
|
7989
|
+
output.add(this.denominator[0]);
|
|
7867
7990
|
}
|
|
7868
7991
|
};
|
|
7869
7992
|
Unit.prototype.toString = function () {
|
|
@@ -8041,7 +8164,7 @@ Value.prototype.eval = function (context) {
|
|
|
8041
8164
|
};
|
|
8042
8165
|
Value.prototype.genCSS = function (context, output) {
|
|
8043
8166
|
var i;
|
|
8044
|
-
for(i = 0; i < this.value.length; i++) {
|
|
8167
|
+
for (i = 0; i < this.value.length; i++) {
|
|
8045
8168
|
this.value[i].genCSS(context, output);
|
|
8046
8169
|
if (i + 1 < this.value.length) {
|
|
8047
8170
|
output.add((context && context.compress) ? ',' : ', ');
|
|
@@ -8161,7 +8284,7 @@ ExtendFinderVisitor.prototype = {
|
|
|
8161
8284
|
|
|
8162
8285
|
// get &:extend(.a); rules which apply to all selectors in this ruleset
|
|
8163
8286
|
var rules = rulesetNode.rules, ruleCnt = rules ? rules.length : 0;
|
|
8164
|
-
for(i = 0; i < ruleCnt; i++) {
|
|
8287
|
+
for (i = 0; i < ruleCnt; i++) {
|
|
8165
8288
|
if (rulesetNode.rules[i] instanceof tree.Extend) {
|
|
8166
8289
|
allSelectorsExtendList.push(rules[i]);
|
|
8167
8290
|
rulesetNode.extendOnEveryPath = true;
|
|
@@ -8171,7 +8294,7 @@ ExtendFinderVisitor.prototype = {
|
|
|
8171
8294
|
// now find every selector and apply the extends that apply to all extends
|
|
8172
8295
|
// and the ones which apply to an individual extend
|
|
8173
8296
|
var paths = rulesetNode.paths;
|
|
8174
|
-
for(i = 0; i < paths.length; i++) {
|
|
8297
|
+
for (i = 0; i < paths.length; i++) {
|
|
8175
8298
|
var selectorPath = paths[i],
|
|
8176
8299
|
selector = selectorPath[selectorPath.length - 1],
|
|
8177
8300
|
selExtendList = selector.extendList;
|
|
@@ -8185,7 +8308,7 @@ ExtendFinderVisitor.prototype = {
|
|
|
8185
8308
|
});
|
|
8186
8309
|
}
|
|
8187
8310
|
|
|
8188
|
-
for(j = 0; j < extendList.length; j++) {
|
|
8311
|
+
for (j = 0; j < extendList.length; j++) {
|
|
8189
8312
|
this.foundExtends = true;
|
|
8190
8313
|
extend = extendList[j];
|
|
8191
8314
|
extend.findSelfSelectors(selectorPath);
|
|
@@ -8242,9 +8365,10 @@ ProcessExtendsVisitor.prototype = {
|
|
|
8242
8365
|
var selector = "_unknown_";
|
|
8243
8366
|
try {
|
|
8244
8367
|
selector = extend.selector.toCSS({});
|
|
8245
|
-
}
|
|
8368
|
+
}
|
|
8369
|
+
catch(_) {}
|
|
8246
8370
|
|
|
8247
|
-
if(!indicies[extend.index + ' ' + selector]) {
|
|
8371
|
+
if (!indicies[extend.index + ' ' + selector]) {
|
|
8248
8372
|
indicies[extend.index + ' ' + selector] = true;
|
|
8249
8373
|
logger.warn("extend '" + selector + "' has no matches");
|
|
8250
8374
|
}
|
|
@@ -8271,14 +8395,14 @@ ProcessExtendsVisitor.prototype = {
|
|
|
8271
8395
|
// and the second is the target.
|
|
8272
8396
|
// the seperation into two lists allows us to process a subset of chains with a bigger set, as is the
|
|
8273
8397
|
// case when processing media queries
|
|
8274
|
-
for(extendIndex = 0; extendIndex < extendsList.length; extendIndex++){
|
|
8275
|
-
for(targetExtendIndex = 0; targetExtendIndex < extendsListTarget.length; targetExtendIndex++){
|
|
8398
|
+
for (extendIndex = 0; extendIndex < extendsList.length; extendIndex++) {
|
|
8399
|
+
for (targetExtendIndex = 0; targetExtendIndex < extendsListTarget.length; targetExtendIndex++) {
|
|
8276
8400
|
|
|
8277
8401
|
extend = extendsList[extendIndex];
|
|
8278
8402
|
targetExtend = extendsListTarget[targetExtendIndex];
|
|
8279
8403
|
|
|
8280
8404
|
// look for circular references
|
|
8281
|
-
if( extend.parent_ids.indexOf( targetExtend.object_id ) >= 0 ){ continue; }
|
|
8405
|
+
if ( extend.parent_ids.indexOf( targetExtend.object_id ) >= 0 ) { continue; }
|
|
8282
8406
|
|
|
8283
8407
|
// find a match in the target extends self selector (the bit before :extend)
|
|
8284
8408
|
selectorPath = [targetExtend.selfSelectors[0]];
|
|
@@ -8362,8 +8486,8 @@ ProcessExtendsVisitor.prototype = {
|
|
|
8362
8486
|
|
|
8363
8487
|
// look at each selector path in the ruleset, find any extend matches and then copy, find and replace
|
|
8364
8488
|
|
|
8365
|
-
for(extendIndex = 0; extendIndex < allExtends.length; extendIndex++) {
|
|
8366
|
-
for(pathIndex = 0; pathIndex < rulesetNode.paths.length; pathIndex++) {
|
|
8489
|
+
for (extendIndex = 0; extendIndex < allExtends.length; extendIndex++) {
|
|
8490
|
+
for (pathIndex = 0; pathIndex < rulesetNode.paths.length; pathIndex++) {
|
|
8367
8491
|
selectorPath = rulesetNode.paths[pathIndex];
|
|
8368
8492
|
|
|
8369
8493
|
// extending extends happens initially, before the main pass
|
|
@@ -8396,10 +8520,10 @@ ProcessExtendsVisitor.prototype = {
|
|
|
8396
8520
|
potentialMatches = [], potentialMatch, matches = [];
|
|
8397
8521
|
|
|
8398
8522
|
// loop through the haystack elements
|
|
8399
|
-
for(haystackSelectorIndex = 0; haystackSelectorIndex < haystackSelectorPath.length; haystackSelectorIndex++) {
|
|
8523
|
+
for (haystackSelectorIndex = 0; haystackSelectorIndex < haystackSelectorPath.length; haystackSelectorIndex++) {
|
|
8400
8524
|
hackstackSelector = haystackSelectorPath[haystackSelectorIndex];
|
|
8401
8525
|
|
|
8402
|
-
for(hackstackElementIndex = 0; hackstackElementIndex < hackstackSelector.elements.length; hackstackElementIndex++) {
|
|
8526
|
+
for (hackstackElementIndex = 0; hackstackElementIndex < hackstackSelector.elements.length; hackstackElementIndex++) {
|
|
8403
8527
|
|
|
8404
8528
|
haystackElement = hackstackSelector.elements[hackstackElementIndex];
|
|
8405
8529
|
|
|
@@ -8409,7 +8533,7 @@ ProcessExtendsVisitor.prototype = {
|
|
|
8409
8533
|
initialCombinator: haystackElement.combinator});
|
|
8410
8534
|
}
|
|
8411
8535
|
|
|
8412
|
-
for(i = 0; i < potentialMatches.length; i++) {
|
|
8536
|
+
for (i = 0; i < potentialMatches.length; i++) {
|
|
8413
8537
|
potentialMatch = potentialMatches[i];
|
|
8414
8538
|
|
|
8415
8539
|
// selectors add " " onto the first element. When we use & it joins the selectors together, but if we don't
|
|
@@ -8479,7 +8603,7 @@ ProcessExtendsVisitor.prototype = {
|
|
|
8479
8603
|
if (!(elementValue2 instanceof tree.Selector) || elementValue1.elements.length !== elementValue2.elements.length) {
|
|
8480
8604
|
return false;
|
|
8481
8605
|
}
|
|
8482
|
-
for(var i = 0; i < elementValue1.elements.length; i++) {
|
|
8606
|
+
for (var i = 0; i < elementValue1.elements.length; i++) {
|
|
8483
8607
|
if (elementValue1.elements[i].combinator.value !== elementValue2.elements[i].combinator.value) {
|
|
8484
8608
|
if (i !== 0 || (elementValue1.elements[i].combinator.value || ' ') !== (elementValue2.elements[i].combinator.value || ' ')) {
|
|
8485
8609
|
return false;
|
|
@@ -8612,8 +8736,8 @@ ImportSequencer.prototype.addVariableImport = function(callback) {
|
|
|
8612
8736
|
ImportSequencer.prototype.tryRun = function() {
|
|
8613
8737
|
this._currentDepth++;
|
|
8614
8738
|
try {
|
|
8615
|
-
while(true) {
|
|
8616
|
-
while(this.imports.length > 0) {
|
|
8739
|
+
while (true) {
|
|
8740
|
+
while (this.imports.length > 0) {
|
|
8617
8741
|
var importItem = this.imports[0];
|
|
8618
8742
|
if (!importItem.isReady) {
|
|
8619
8743
|
return;
|
|
@@ -8698,7 +8822,7 @@ ImportVisitor.prototype = {
|
|
|
8698
8822
|
|
|
8699
8823
|
try {
|
|
8700
8824
|
evaldImportNode = importNode.evalForImport(context);
|
|
8701
|
-
} catch(e){
|
|
8825
|
+
} catch(e) {
|
|
8702
8826
|
if (!e.filename) { e.index = importNode.index; e.filename = importNode.currentFileInfo.filename; }
|
|
8703
8827
|
// attempt to eval properly and treat as css
|
|
8704
8828
|
importNode.css = true;
|
|
@@ -8715,7 +8839,7 @@ ImportVisitor.prototype = {
|
|
|
8715
8839
|
// try appending if we haven't determined if it is css or not
|
|
8716
8840
|
var tryAppendLessExtension = evaldImportNode.css === undefined;
|
|
8717
8841
|
|
|
8718
|
-
for(var i = 0; i < importParent.rules.length; i++) {
|
|
8842
|
+
for (var i = 0; i < importParent.rules.length; i++) {
|
|
8719
8843
|
if (importParent.rules[i] === importNode) {
|
|
8720
8844
|
importParent.rules[i] = evaldImportNode;
|
|
8721
8845
|
break;
|
|
@@ -8978,7 +9102,7 @@ ToCSSVisitor.prototype = {
|
|
|
8978
9102
|
|
|
8979
9103
|
checkPropertiesInRoot: function(rules) {
|
|
8980
9104
|
var ruleNode;
|
|
8981
|
-
for(var i = 0; i < rules.length; i++) {
|
|
9105
|
+
for (var i = 0; i < rules.length; i++) {
|
|
8982
9106
|
ruleNode = rules[i];
|
|
8983
9107
|
if (ruleNode instanceof tree.Rule && !ruleNode.variable) {
|
|
8984
9108
|
throw { message: "properties must be inside selector blocks, they cannot be in the root.",
|
|
@@ -9000,7 +9124,7 @@ ToCSSVisitor.prototype = {
|
|
|
9000
9124
|
if (p[0].elements[0].combinator.value === ' ') {
|
|
9001
9125
|
p[0].elements[0].combinator = new(tree.Combinator)('');
|
|
9002
9126
|
}
|
|
9003
|
-
for(i = 0; i < p.length; i++) {
|
|
9127
|
+
for (i = 0; i < p.length; i++) {
|
|
9004
9128
|
if (p[i].getIsReferenced() && p[i].getIsOutput()) {
|
|
9005
9129
|
return true;
|
|
9006
9130
|
}
|
|
@@ -9065,7 +9189,7 @@ ToCSSVisitor.prototype = {
|
|
|
9065
9189
|
var ruleCache = {},
|
|
9066
9190
|
ruleList, rule, i;
|
|
9067
9191
|
|
|
9068
|
-
for(i = rules.length - 1; i >= 0 ; i--) {
|
|
9192
|
+
for (i = rules.length - 1; i >= 0 ; i--) {
|
|
9069
9193
|
rule = rules[i];
|
|
9070
9194
|
if (rule instanceof tree.Rule) {
|
|
9071
9195
|
if (!ruleCache[rule.name]) {
|
|
@@ -9132,8 +9256,8 @@ ToCSSVisitor.prototype = {
|
|
|
9132
9256
|
var spacedGroups = [];
|
|
9133
9257
|
var lastSpacedGroup = [];
|
|
9134
9258
|
parts.map(function (p) {
|
|
9135
|
-
|
|
9136
|
-
|
|
9259
|
+
if (p.merge === "+") {
|
|
9260
|
+
if (lastSpacedGroup.length > 0) {
|
|
9137
9261
|
spacedGroups.push(toExpression(lastSpacedGroup));
|
|
9138
9262
|
}
|
|
9139
9263
|
lastSpacedGroup = [];
|
|
@@ -9307,69 +9431,39 @@ module.exports = Visitor;
|
|
|
9307
9431
|
// shim for using process in browser
|
|
9308
9432
|
|
|
9309
9433
|
var process = module.exports = {};
|
|
9434
|
+
var queue = [];
|
|
9435
|
+
var draining = false;
|
|
9310
9436
|
|
|
9311
|
-
|
|
9312
|
-
|
|
9313
|
-
|
|
9314
|
-
var canMutationObserver = typeof window !== 'undefined'
|
|
9315
|
-
&& window.MutationObserver;
|
|
9316
|
-
var canPost = typeof window !== 'undefined'
|
|
9317
|
-
&& window.postMessage && window.addEventListener
|
|
9318
|
-
;
|
|
9319
|
-
|
|
9320
|
-
if (canSetImmediate) {
|
|
9321
|
-
return function (f) { return window.setImmediate(f) };
|
|
9437
|
+
function drainQueue() {
|
|
9438
|
+
if (draining) {
|
|
9439
|
+
return;
|
|
9322
9440
|
}
|
|
9323
|
-
|
|
9324
|
-
var
|
|
9325
|
-
|
|
9326
|
-
|
|
9327
|
-
|
|
9328
|
-
|
|
9329
|
-
|
|
9330
|
-
|
|
9331
|
-
|
|
9332
|
-
|
|
9333
|
-
|
|
9334
|
-
});
|
|
9335
|
-
|
|
9336
|
-
observer.observe(hiddenDiv, { attributes: true });
|
|
9337
|
-
|
|
9338
|
-
return function nextTick(fn) {
|
|
9339
|
-
if (!queue.length) {
|
|
9340
|
-
hiddenDiv.setAttribute('yes', 'no');
|
|
9341
|
-
}
|
|
9342
|
-
queue.push(fn);
|
|
9343
|
-
};
|
|
9441
|
+
draining = true;
|
|
9442
|
+
var currentQueue;
|
|
9443
|
+
var len = queue.length;
|
|
9444
|
+
while(len) {
|
|
9445
|
+
currentQueue = queue;
|
|
9446
|
+
queue = [];
|
|
9447
|
+
var i = -1;
|
|
9448
|
+
while (++i < len) {
|
|
9449
|
+
currentQueue[i]();
|
|
9450
|
+
}
|
|
9451
|
+
len = queue.length;
|
|
9344
9452
|
}
|
|
9345
|
-
|
|
9346
|
-
|
|
9347
|
-
|
|
9348
|
-
|
|
9349
|
-
|
|
9350
|
-
|
|
9351
|
-
if (queue.length > 0) {
|
|
9352
|
-
var fn = queue.shift();
|
|
9353
|
-
fn();
|
|
9354
|
-
}
|
|
9355
|
-
}
|
|
9356
|
-
}, true);
|
|
9357
|
-
|
|
9358
|
-
return function nextTick(fn) {
|
|
9359
|
-
queue.push(fn);
|
|
9360
|
-
window.postMessage('process-tick', '*');
|
|
9361
|
-
};
|
|
9453
|
+
draining = false;
|
|
9454
|
+
}
|
|
9455
|
+
process.nextTick = function (fun) {
|
|
9456
|
+
queue.push(fun);
|
|
9457
|
+
if (!draining) {
|
|
9458
|
+
setTimeout(drainQueue, 0);
|
|
9362
9459
|
}
|
|
9363
|
-
|
|
9364
|
-
return function nextTick(fn) {
|
|
9365
|
-
setTimeout(fn, 0);
|
|
9366
|
-
};
|
|
9367
|
-
})();
|
|
9460
|
+
};
|
|
9368
9461
|
|
|
9369
9462
|
process.title = 'browser';
|
|
9370
9463
|
process.browser = true;
|
|
9371
9464
|
process.env = {};
|
|
9372
9465
|
process.argv = [];
|
|
9466
|
+
process.version = ''; // empty string to avoid regexp issues
|
|
9373
9467
|
|
|
9374
9468
|
function noop() {}
|
|
9375
9469
|
|
|
@@ -9390,223 +9484,224 @@ process.cwd = function () { return '/' };
|
|
|
9390
9484
|
process.chdir = function (dir) {
|
|
9391
9485
|
throw new Error('process.chdir is not supported');
|
|
9392
9486
|
};
|
|
9487
|
+
process.umask = function() { return 0; };
|
|
9393
9488
|
|
|
9394
9489
|
},{}],89:[function(require,module,exports){
|
|
9395
|
-
'use strict';
|
|
9396
|
-
|
|
9397
|
-
var asap = require('asap')
|
|
9398
|
-
|
|
9399
|
-
module.exports = Promise;
|
|
9400
|
-
function Promise(fn) {
|
|
9401
|
-
if (typeof this !== 'object') throw new TypeError('Promises must be constructed via new')
|
|
9402
|
-
if (typeof fn !== 'function') throw new TypeError('not a function')
|
|
9403
|
-
var state = null
|
|
9404
|
-
var value = null
|
|
9405
|
-
var deferreds = []
|
|
9406
|
-
var self = this
|
|
9407
|
-
|
|
9408
|
-
this.then = function(onFulfilled, onRejected) {
|
|
9409
|
-
return new self.constructor(function(resolve, reject) {
|
|
9410
|
-
handle(new Handler(onFulfilled, onRejected, resolve, reject))
|
|
9411
|
-
})
|
|
9412
|
-
}
|
|
9413
|
-
|
|
9414
|
-
function handle(deferred) {
|
|
9415
|
-
if (state === null) {
|
|
9416
|
-
deferreds.push(deferred)
|
|
9417
|
-
return
|
|
9418
|
-
}
|
|
9419
|
-
asap(function() {
|
|
9420
|
-
var cb = state ? deferred.onFulfilled : deferred.onRejected
|
|
9421
|
-
if (cb === null) {
|
|
9422
|
-
(state ? deferred.resolve : deferred.reject)(value)
|
|
9423
|
-
return
|
|
9424
|
-
}
|
|
9425
|
-
var ret
|
|
9426
|
-
try {
|
|
9427
|
-
ret = cb(value)
|
|
9428
|
-
}
|
|
9429
|
-
catch (e) {
|
|
9430
|
-
deferred.reject(e)
|
|
9431
|
-
return
|
|
9432
|
-
}
|
|
9433
|
-
deferred.resolve(ret)
|
|
9434
|
-
})
|
|
9435
|
-
}
|
|
9436
|
-
|
|
9437
|
-
function resolve(newValue) {
|
|
9438
|
-
try { //Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure
|
|
9439
|
-
if (newValue === self) throw new TypeError('A promise cannot be resolved with itself.')
|
|
9440
|
-
if (newValue && (typeof newValue === 'object' || typeof newValue === 'function')) {
|
|
9441
|
-
var then = newValue.then
|
|
9442
|
-
if (typeof then === 'function') {
|
|
9443
|
-
doResolve(then.bind(newValue), resolve, reject)
|
|
9444
|
-
return
|
|
9445
|
-
}
|
|
9446
|
-
}
|
|
9447
|
-
state = true
|
|
9448
|
-
value = newValue
|
|
9449
|
-
finale()
|
|
9450
|
-
} catch (e) { reject(e) }
|
|
9451
|
-
}
|
|
9452
|
-
|
|
9453
|
-
function reject(newValue) {
|
|
9454
|
-
state = false
|
|
9455
|
-
value = newValue
|
|
9456
|
-
finale()
|
|
9457
|
-
}
|
|
9458
|
-
|
|
9459
|
-
function finale() {
|
|
9460
|
-
for (var i = 0, len = deferreds.length; i < len; i++)
|
|
9461
|
-
handle(deferreds[i])
|
|
9462
|
-
deferreds = null
|
|
9463
|
-
}
|
|
9464
|
-
|
|
9465
|
-
doResolve(fn, resolve, reject)
|
|
9466
|
-
}
|
|
9467
|
-
|
|
9468
|
-
|
|
9469
|
-
function Handler(onFulfilled, onRejected, resolve, reject){
|
|
9470
|
-
this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null
|
|
9471
|
-
this.onRejected = typeof onRejected === 'function' ? onRejected : null
|
|
9472
|
-
this.resolve = resolve
|
|
9473
|
-
this.reject = reject
|
|
9474
|
-
}
|
|
9475
|
-
|
|
9476
|
-
/**
|
|
9477
|
-
* Take a potentially misbehaving resolver function and make sure
|
|
9478
|
-
* onFulfilled and onRejected are only called once.
|
|
9479
|
-
*
|
|
9480
|
-
* Makes no guarantees about asynchrony.
|
|
9481
|
-
*/
|
|
9482
|
-
function doResolve(fn, onFulfilled, onRejected) {
|
|
9483
|
-
var done = false;
|
|
9484
|
-
try {
|
|
9485
|
-
fn(function (value) {
|
|
9486
|
-
if (done) return
|
|
9487
|
-
done = true
|
|
9488
|
-
onFulfilled(value)
|
|
9489
|
-
}, function (reason) {
|
|
9490
|
-
if (done) return
|
|
9491
|
-
done = true
|
|
9492
|
-
onRejected(reason)
|
|
9493
|
-
})
|
|
9494
|
-
} catch (ex) {
|
|
9495
|
-
if (done) return
|
|
9496
|
-
done = true
|
|
9497
|
-
onRejected(ex)
|
|
9498
|
-
}
|
|
9499
|
-
}
|
|
9490
|
+
'use strict';
|
|
9491
|
+
|
|
9492
|
+
var asap = require('asap')
|
|
9493
|
+
|
|
9494
|
+
module.exports = Promise;
|
|
9495
|
+
function Promise(fn) {
|
|
9496
|
+
if (typeof this !== 'object') throw new TypeError('Promises must be constructed via new')
|
|
9497
|
+
if (typeof fn !== 'function') throw new TypeError('not a function')
|
|
9498
|
+
var state = null
|
|
9499
|
+
var value = null
|
|
9500
|
+
var deferreds = []
|
|
9501
|
+
var self = this
|
|
9502
|
+
|
|
9503
|
+
this.then = function(onFulfilled, onRejected) {
|
|
9504
|
+
return new self.constructor(function(resolve, reject) {
|
|
9505
|
+
handle(new Handler(onFulfilled, onRejected, resolve, reject))
|
|
9506
|
+
})
|
|
9507
|
+
}
|
|
9508
|
+
|
|
9509
|
+
function handle(deferred) {
|
|
9510
|
+
if (state === null) {
|
|
9511
|
+
deferreds.push(deferred)
|
|
9512
|
+
return
|
|
9513
|
+
}
|
|
9514
|
+
asap(function() {
|
|
9515
|
+
var cb = state ? deferred.onFulfilled : deferred.onRejected
|
|
9516
|
+
if (cb === null) {
|
|
9517
|
+
(state ? deferred.resolve : deferred.reject)(value)
|
|
9518
|
+
return
|
|
9519
|
+
}
|
|
9520
|
+
var ret
|
|
9521
|
+
try {
|
|
9522
|
+
ret = cb(value)
|
|
9523
|
+
}
|
|
9524
|
+
catch (e) {
|
|
9525
|
+
deferred.reject(e)
|
|
9526
|
+
return
|
|
9527
|
+
}
|
|
9528
|
+
deferred.resolve(ret)
|
|
9529
|
+
})
|
|
9530
|
+
}
|
|
9531
|
+
|
|
9532
|
+
function resolve(newValue) {
|
|
9533
|
+
try { //Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure
|
|
9534
|
+
if (newValue === self) throw new TypeError('A promise cannot be resolved with itself.')
|
|
9535
|
+
if (newValue && (typeof newValue === 'object' || typeof newValue === 'function')) {
|
|
9536
|
+
var then = newValue.then
|
|
9537
|
+
if (typeof then === 'function') {
|
|
9538
|
+
doResolve(then.bind(newValue), resolve, reject)
|
|
9539
|
+
return
|
|
9540
|
+
}
|
|
9541
|
+
}
|
|
9542
|
+
state = true
|
|
9543
|
+
value = newValue
|
|
9544
|
+
finale()
|
|
9545
|
+
} catch (e) { reject(e) }
|
|
9546
|
+
}
|
|
9547
|
+
|
|
9548
|
+
function reject(newValue) {
|
|
9549
|
+
state = false
|
|
9550
|
+
value = newValue
|
|
9551
|
+
finale()
|
|
9552
|
+
}
|
|
9553
|
+
|
|
9554
|
+
function finale() {
|
|
9555
|
+
for (var i = 0, len = deferreds.length; i < len; i++)
|
|
9556
|
+
handle(deferreds[i])
|
|
9557
|
+
deferreds = null
|
|
9558
|
+
}
|
|
9559
|
+
|
|
9560
|
+
doResolve(fn, resolve, reject)
|
|
9561
|
+
}
|
|
9562
|
+
|
|
9563
|
+
|
|
9564
|
+
function Handler(onFulfilled, onRejected, resolve, reject){
|
|
9565
|
+
this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null
|
|
9566
|
+
this.onRejected = typeof onRejected === 'function' ? onRejected : null
|
|
9567
|
+
this.resolve = resolve
|
|
9568
|
+
this.reject = reject
|
|
9569
|
+
}
|
|
9570
|
+
|
|
9571
|
+
/**
|
|
9572
|
+
* Take a potentially misbehaving resolver function and make sure
|
|
9573
|
+
* onFulfilled and onRejected are only called once.
|
|
9574
|
+
*
|
|
9575
|
+
* Makes no guarantees about asynchrony.
|
|
9576
|
+
*/
|
|
9577
|
+
function doResolve(fn, onFulfilled, onRejected) {
|
|
9578
|
+
var done = false;
|
|
9579
|
+
try {
|
|
9580
|
+
fn(function (value) {
|
|
9581
|
+
if (done) return
|
|
9582
|
+
done = true
|
|
9583
|
+
onFulfilled(value)
|
|
9584
|
+
}, function (reason) {
|
|
9585
|
+
if (done) return
|
|
9586
|
+
done = true
|
|
9587
|
+
onRejected(reason)
|
|
9588
|
+
})
|
|
9589
|
+
} catch (ex) {
|
|
9590
|
+
if (done) return
|
|
9591
|
+
done = true
|
|
9592
|
+
onRejected(ex)
|
|
9593
|
+
}
|
|
9594
|
+
}
|
|
9500
9595
|
|
|
9501
9596
|
},{"asap":91}],90:[function(require,module,exports){
|
|
9502
|
-
'use strict';
|
|
9503
|
-
|
|
9504
|
-
//This file contains the ES6 extensions to the core Promises/A+ API
|
|
9505
|
-
|
|
9506
|
-
var Promise = require('./core.js')
|
|
9507
|
-
var asap = require('asap')
|
|
9508
|
-
|
|
9509
|
-
module.exports = Promise
|
|
9510
|
-
|
|
9511
|
-
/* Static Functions */
|
|
9512
|
-
|
|
9513
|
-
function ValuePromise(value) {
|
|
9514
|
-
this.then = function (onFulfilled) {
|
|
9515
|
-
if (typeof onFulfilled !== 'function') return this
|
|
9516
|
-
return new Promise(function (resolve, reject) {
|
|
9517
|
-
asap(function () {
|
|
9518
|
-
try {
|
|
9519
|
-
resolve(onFulfilled(value))
|
|
9520
|
-
} catch (ex) {
|
|
9521
|
-
reject(ex);
|
|
9522
|
-
}
|
|
9523
|
-
})
|
|
9524
|
-
})
|
|
9525
|
-
}
|
|
9526
|
-
}
|
|
9527
|
-
ValuePromise.prototype = Promise.prototype
|
|
9528
|
-
|
|
9529
|
-
var TRUE = new ValuePromise(true)
|
|
9530
|
-
var FALSE = new ValuePromise(false)
|
|
9531
|
-
var NULL = new ValuePromise(null)
|
|
9532
|
-
var UNDEFINED = new ValuePromise(undefined)
|
|
9533
|
-
var ZERO = new ValuePromise(0)
|
|
9534
|
-
var EMPTYSTRING = new ValuePromise('')
|
|
9535
|
-
|
|
9536
|
-
Promise.resolve = function (value) {
|
|
9537
|
-
if (value instanceof Promise) return value
|
|
9538
|
-
|
|
9539
|
-
if (value === null) return NULL
|
|
9540
|
-
if (value === undefined) return UNDEFINED
|
|
9541
|
-
if (value === true) return TRUE
|
|
9542
|
-
if (value === false) return FALSE
|
|
9543
|
-
if (value === 0) return ZERO
|
|
9544
|
-
if (value === '') return EMPTYSTRING
|
|
9545
|
-
|
|
9546
|
-
if (typeof value === 'object' || typeof value === 'function') {
|
|
9547
|
-
try {
|
|
9548
|
-
var then = value.then
|
|
9549
|
-
if (typeof then === 'function') {
|
|
9550
|
-
return new Promise(then.bind(value))
|
|
9551
|
-
}
|
|
9552
|
-
} catch (ex) {
|
|
9553
|
-
return new Promise(function (resolve, reject) {
|
|
9554
|
-
reject(ex)
|
|
9555
|
-
})
|
|
9556
|
-
}
|
|
9557
|
-
}
|
|
9558
|
-
|
|
9559
|
-
return new ValuePromise(value)
|
|
9560
|
-
}
|
|
9561
|
-
|
|
9562
|
-
Promise.all = function (arr) {
|
|
9563
|
-
var args = Array.prototype.slice.call(arr)
|
|
9564
|
-
|
|
9565
|
-
return new Promise(function (resolve, reject) {
|
|
9566
|
-
if (args.length === 0) return resolve([])
|
|
9567
|
-
var remaining = args.length
|
|
9568
|
-
function res(i, val) {
|
|
9569
|
-
try {
|
|
9570
|
-
if (val && (typeof val === 'object' || typeof val === 'function')) {
|
|
9571
|
-
var then = val.then
|
|
9572
|
-
if (typeof then === 'function') {
|
|
9573
|
-
then.call(val, function (val) { res(i, val) }, reject)
|
|
9574
|
-
return
|
|
9575
|
-
}
|
|
9576
|
-
}
|
|
9577
|
-
args[i] = val
|
|
9578
|
-
if (--remaining === 0) {
|
|
9579
|
-
resolve(args);
|
|
9580
|
-
}
|
|
9581
|
-
} catch (ex) {
|
|
9582
|
-
reject(ex)
|
|
9583
|
-
}
|
|
9584
|
-
}
|
|
9585
|
-
for (var i = 0; i < args.length; i++) {
|
|
9586
|
-
res(i, args[i])
|
|
9587
|
-
}
|
|
9588
|
-
})
|
|
9589
|
-
}
|
|
9590
|
-
|
|
9591
|
-
Promise.reject = function (value) {
|
|
9592
|
-
return new Promise(function (resolve, reject) {
|
|
9593
|
-
reject(value);
|
|
9594
|
-
});
|
|
9595
|
-
}
|
|
9596
|
-
|
|
9597
|
-
Promise.race = function (values) {
|
|
9598
|
-
return new Promise(function (resolve, reject) {
|
|
9599
|
-
values.forEach(function(value){
|
|
9600
|
-
Promise.resolve(value).then(resolve, reject);
|
|
9601
|
-
})
|
|
9602
|
-
});
|
|
9603
|
-
}
|
|
9604
|
-
|
|
9605
|
-
/* Prototype Methods */
|
|
9606
|
-
|
|
9607
|
-
Promise.prototype['catch'] = function (onRejected) {
|
|
9608
|
-
return this.then(null, onRejected);
|
|
9609
|
-
}
|
|
9597
|
+
'use strict';
|
|
9598
|
+
|
|
9599
|
+
//This file contains the ES6 extensions to the core Promises/A+ API
|
|
9600
|
+
|
|
9601
|
+
var Promise = require('./core.js')
|
|
9602
|
+
var asap = require('asap')
|
|
9603
|
+
|
|
9604
|
+
module.exports = Promise
|
|
9605
|
+
|
|
9606
|
+
/* Static Functions */
|
|
9607
|
+
|
|
9608
|
+
function ValuePromise(value) {
|
|
9609
|
+
this.then = function (onFulfilled) {
|
|
9610
|
+
if (typeof onFulfilled !== 'function') return this
|
|
9611
|
+
return new Promise(function (resolve, reject) {
|
|
9612
|
+
asap(function () {
|
|
9613
|
+
try {
|
|
9614
|
+
resolve(onFulfilled(value))
|
|
9615
|
+
} catch (ex) {
|
|
9616
|
+
reject(ex);
|
|
9617
|
+
}
|
|
9618
|
+
})
|
|
9619
|
+
})
|
|
9620
|
+
}
|
|
9621
|
+
}
|
|
9622
|
+
ValuePromise.prototype = Promise.prototype
|
|
9623
|
+
|
|
9624
|
+
var TRUE = new ValuePromise(true)
|
|
9625
|
+
var FALSE = new ValuePromise(false)
|
|
9626
|
+
var NULL = new ValuePromise(null)
|
|
9627
|
+
var UNDEFINED = new ValuePromise(undefined)
|
|
9628
|
+
var ZERO = new ValuePromise(0)
|
|
9629
|
+
var EMPTYSTRING = new ValuePromise('')
|
|
9630
|
+
|
|
9631
|
+
Promise.resolve = function (value) {
|
|
9632
|
+
if (value instanceof Promise) return value
|
|
9633
|
+
|
|
9634
|
+
if (value === null) return NULL
|
|
9635
|
+
if (value === undefined) return UNDEFINED
|
|
9636
|
+
if (value === true) return TRUE
|
|
9637
|
+
if (value === false) return FALSE
|
|
9638
|
+
if (value === 0) return ZERO
|
|
9639
|
+
if (value === '') return EMPTYSTRING
|
|
9640
|
+
|
|
9641
|
+
if (typeof value === 'object' || typeof value === 'function') {
|
|
9642
|
+
try {
|
|
9643
|
+
var then = value.then
|
|
9644
|
+
if (typeof then === 'function') {
|
|
9645
|
+
return new Promise(then.bind(value))
|
|
9646
|
+
}
|
|
9647
|
+
} catch (ex) {
|
|
9648
|
+
return new Promise(function (resolve, reject) {
|
|
9649
|
+
reject(ex)
|
|
9650
|
+
})
|
|
9651
|
+
}
|
|
9652
|
+
}
|
|
9653
|
+
|
|
9654
|
+
return new ValuePromise(value)
|
|
9655
|
+
}
|
|
9656
|
+
|
|
9657
|
+
Promise.all = function (arr) {
|
|
9658
|
+
var args = Array.prototype.slice.call(arr)
|
|
9659
|
+
|
|
9660
|
+
return new Promise(function (resolve, reject) {
|
|
9661
|
+
if (args.length === 0) return resolve([])
|
|
9662
|
+
var remaining = args.length
|
|
9663
|
+
function res(i, val) {
|
|
9664
|
+
try {
|
|
9665
|
+
if (val && (typeof val === 'object' || typeof val === 'function')) {
|
|
9666
|
+
var then = val.then
|
|
9667
|
+
if (typeof then === 'function') {
|
|
9668
|
+
then.call(val, function (val) { res(i, val) }, reject)
|
|
9669
|
+
return
|
|
9670
|
+
}
|
|
9671
|
+
}
|
|
9672
|
+
args[i] = val
|
|
9673
|
+
if (--remaining === 0) {
|
|
9674
|
+
resolve(args);
|
|
9675
|
+
}
|
|
9676
|
+
} catch (ex) {
|
|
9677
|
+
reject(ex)
|
|
9678
|
+
}
|
|
9679
|
+
}
|
|
9680
|
+
for (var i = 0; i < args.length; i++) {
|
|
9681
|
+
res(i, args[i])
|
|
9682
|
+
}
|
|
9683
|
+
})
|
|
9684
|
+
}
|
|
9685
|
+
|
|
9686
|
+
Promise.reject = function (value) {
|
|
9687
|
+
return new Promise(function (resolve, reject) {
|
|
9688
|
+
reject(value);
|
|
9689
|
+
});
|
|
9690
|
+
}
|
|
9691
|
+
|
|
9692
|
+
Promise.race = function (values) {
|
|
9693
|
+
return new Promise(function (resolve, reject) {
|
|
9694
|
+
values.forEach(function(value){
|
|
9695
|
+
Promise.resolve(value).then(resolve, reject);
|
|
9696
|
+
})
|
|
9697
|
+
});
|
|
9698
|
+
}
|
|
9699
|
+
|
|
9700
|
+
/* Prototype Methods */
|
|
9701
|
+
|
|
9702
|
+
Promise.prototype['catch'] = function (onRejected) {
|
|
9703
|
+
return this.then(null, onRejected);
|
|
9704
|
+
}
|
|
9610
9705
|
|
|
9611
9706
|
},{"./core.js":89,"asap":91}],91:[function(require,module,exports){
|
|
9612
9707
|
(function (process){
|
|
@@ -9726,29 +9821,29 @@ module.exports = asap;
|
|
|
9726
9821
|
|
|
9727
9822
|
}).call(this,require('_process'))
|
|
9728
9823
|
},{"_process":88}],92:[function(require,module,exports){
|
|
9729
|
-
// should work in any browser without browserify
|
|
9730
|
-
|
|
9731
|
-
if (typeof Promise.prototype.done !== 'function') {
|
|
9732
|
-
Promise.prototype.done = function (onFulfilled, onRejected) {
|
|
9733
|
-
var self = arguments.length ? this.then.apply(this, arguments) : this
|
|
9734
|
-
self.then(null, function (err) {
|
|
9735
|
-
setTimeout(function () {
|
|
9736
|
-
throw err
|
|
9737
|
-
}, 0)
|
|
9738
|
-
})
|
|
9739
|
-
}
|
|
9824
|
+
// should work in any browser without browserify
|
|
9825
|
+
|
|
9826
|
+
if (typeof Promise.prototype.done !== 'function') {
|
|
9827
|
+
Promise.prototype.done = function (onFulfilled, onRejected) {
|
|
9828
|
+
var self = arguments.length ? this.then.apply(this, arguments) : this
|
|
9829
|
+
self.then(null, function (err) {
|
|
9830
|
+
setTimeout(function () {
|
|
9831
|
+
throw err
|
|
9832
|
+
}, 0)
|
|
9833
|
+
})
|
|
9834
|
+
}
|
|
9740
9835
|
}
|
|
9741
9836
|
},{}],"promise/polyfill.js":[function(require,module,exports){
|
|
9742
|
-
// not "use strict" so we can declare global "Promise"
|
|
9743
|
-
|
|
9744
|
-
var asap = require('asap');
|
|
9745
|
-
|
|
9746
|
-
if (typeof Promise === 'undefined') {
|
|
9747
|
-
Promise = require('./lib/core.js')
|
|
9748
|
-
require('./lib/es6-extensions.js')
|
|
9749
|
-
}
|
|
9750
|
-
|
|
9751
|
-
require('./polyfill-done.js');
|
|
9837
|
+
// not "use strict" so we can declare global "Promise"
|
|
9838
|
+
|
|
9839
|
+
var asap = require('asap');
|
|
9840
|
+
|
|
9841
|
+
if (typeof Promise === 'undefined') {
|
|
9842
|
+
Promise = require('./lib/core.js')
|
|
9843
|
+
require('./lib/es6-extensions.js')
|
|
9844
|
+
}
|
|
9845
|
+
|
|
9846
|
+
require('./polyfill-done.js');
|
|
9752
9847
|
|
|
9753
9848
|
},{"./lib/core.js":89,"./lib/es6-extensions.js":90,"./polyfill-done.js":92,"asap":91}]},{},[2])(2)
|
|
9754
9849
|
});
|