less 3.9.0 → 3.10.1
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/.DS_Store +0 -0
- package/.eslintignore +4 -1
- package/.eslintrc.json +69 -87
- package/CHANGELOG.md +7 -0
- package/Gruntfile.js +336 -330
- package/bin/lessc +13110 -481
- package/dist/less.cjs.js +12571 -0
- package/dist/less.js +12878 -11507
- package/dist/less.min.js +7 -14
- package/dist/less.min.js.map +1 -0
- package/index.js +1 -1
- package/lib/less/constants.js +12 -12
- package/lib/less/contexts.js +93 -95
- package/lib/less/data/colors.js +1 -1
- package/lib/less/data/index.js +4 -4
- package/lib/less/data/unit-conversions.js +1 -1
- package/lib/less/default-options.js +53 -58
- package/lib/less/environment/abstract-file-manager.js +114 -110
- package/lib/less/environment/abstract-plugin-loader.js +139 -141
- package/lib/less/environment/environment-api.js +1 -1
- package/lib/less/environment/environment.js +44 -41
- package/lib/less/environment/file-manager-api.js +1 -1
- package/lib/less/functions/boolean.js +10 -12
- package/lib/less/functions/color-blending.js +20 -10
- package/lib/less/functions/color.js +63 -49
- package/lib/less/functions/data-uri.js +25 -39
- package/lib/less/functions/default.js +5 -7
- package/lib/less/functions/function-caller.js +42 -39
- package/lib/less/functions/function-registry.js +3 -3
- package/lib/less/functions/index.js +28 -16
- package/lib/less/functions/list.js +34 -28
- package/lib/less/functions/math-helper.js +4 -5
- package/lib/less/functions/math.js +8 -9
- package/lib/less/functions/number.js +26 -18
- package/lib/less/functions/string.js +13 -13
- package/lib/less/functions/svg.js +25 -25
- package/lib/less/functions/types.js +23 -27
- package/lib/less/import-manager.js +140 -138
- package/lib/less/index.js +72 -35
- package/lib/less/less-error.js +29 -30
- package/lib/less/logger.js +4 -4
- package/lib/less/parse-tree.js +53 -47
- package/lib/less/parse.js +23 -25
- package/lib/less/parser/chunker.js +17 -7
- package/lib/less/parser/parser-input.js +100 -93
- package/lib/less/parser/parser.js +310 -170
- package/lib/less/plugin-manager.js +146 -133
- package/lib/less/render.js +10 -13
- package/lib/less/source-map-builder.js +62 -57
- package/lib/less/source-map-output.js +118 -112
- package/lib/less/transform-tree.js +21 -18
- package/lib/less/tree/anonymous.js +35 -27
- package/lib/less/tree/assignment.js +29 -23
- package/lib/less/tree/atrule.js +150 -121
- package/lib/less/tree/attribute.js +32 -25
- package/lib/less/tree/call.js +87 -79
- package/lib/less/tree/color.js +202 -185
- package/lib/less/tree/combinator.js +25 -19
- package/lib/less/tree/comment.js +27 -21
- package/lib/less/tree/condition.js +41 -35
- package/lib/less/tree/debug-info.js +13 -17
- package/lib/less/tree/declaration.js +101 -88
- package/lib/less/tree/detached-ruleset.js +27 -20
- package/lib/less/tree/dimension.js +142 -124
- package/lib/less/tree/element.js +67 -58
- package/lib/less/tree/expression.js +66 -57
- package/lib/less/tree/extend.js +61 -53
- package/lib/less/tree/import.js +144 -141
- package/lib/less/tree/index.js +52 -40
- package/lib/less/tree/javascript.js +29 -25
- package/lib/less/tree/js-eval-node.js +50 -53
- package/lib/less/tree/keyword.js +15 -8
- package/lib/less/tree/media.js +137 -124
- package/lib/less/tree/mixin-call.js +178 -149
- package/lib/less/tree/mixin-definition.js +198 -178
- package/lib/less/tree/namespace-value.js +75 -67
- package/lib/less/tree/negative.js +24 -18
- package/lib/less/tree/node.js +138 -117
- package/lib/less/tree/operation.js +57 -49
- package/lib/less/tree/paren.js +20 -14
- package/lib/less/tree/property.js +65 -58
- package/lib/less/tree/quoted.js +62 -53
- package/lib/less/tree/ruleset.js +739 -680
- package/lib/less/tree/selector.js +129 -114
- package/lib/less/tree/unicode-descriptor.js +10 -6
- package/lib/less/tree/unit.js +117 -97
- package/lib/less/tree/url.js +54 -47
- package/lib/less/tree/value.js +38 -33
- package/lib/less/tree/variable-call.js +41 -34
- package/lib/less/tree/variable.js +58 -51
- package/lib/less/utils.js +110 -108
- package/lib/less/visitors/extend-visitor.js +157 -114
- package/lib/less/visitors/import-sequencer.js +47 -43
- package/lib/less/visitors/import-visitor.js +22 -23
- package/lib/less/visitors/index.js +14 -9
- package/lib/less/visitors/join-selector-visitor.js +32 -26
- package/lib/less/visitors/set-tree-visibility-visitor.js +37 -30
- package/lib/less/visitors/to-css-visitor.js +60 -57
- package/lib/less/visitors/visitor.js +44 -35
- package/lib/less-browser/add-default-options.js +4 -4
- package/lib/less-browser/bootstrap.js +11 -9
- package/lib/less-browser/browser.js +13 -12
- package/lib/less-browser/cache.js +9 -9
- package/lib/less-browser/error-reporting.js +27 -27
- package/lib/less-browser/file-manager.js +37 -35
- package/lib/less-browser/image-size.js +3 -3
- package/lib/less-browser/index.js +78 -73
- package/lib/less-browser/log-listener.js +6 -7
- package/lib/less-browser/plugin-loader.js +15 -13
- package/lib/less-browser/utils.js +20 -20
- package/lib/less-node/environment.js +4 -2
- package/lib/less-node/file-manager.js +128 -127
- package/lib/less-node/fs.js +2 -2
- package/lib/less-node/image-size.js +19 -18
- package/lib/less-node/index.js +16 -12
- package/lib/less-node/lessc-helper.js +4 -5
- package/lib/less-node/plugin-loader.js +41 -40
- package/lib/less-node/url-file-manager.js +41 -48
- package/lib/lessc.js +557 -0
- package/package.json +21 -11
- package/test/.DS_Store +0 -0
- package/test/browser/common.js +34 -30
- package/test/browser/css/urls.css +0 -3
- package/test/browser/less/plugin/plugin.js +4 -7
- package/test/browser/less/urls.less +0 -3
- package/test/browser/less.min.js +11 -0
- package/test/browser/less.min.js.map +1 -0
- package/test/browser/onload.js +13 -0
- package/test/browser/runner-browser-options.js +0 -5
- package/test/browser/test-runner-template.tmpl +39 -52
- package/test/browser/vendor/boot.js +148 -0
- package/test/browser/{jasmine-jsreporter.js → vendor/jasmine-jsreporter.js} +0 -0
- package/test/copy-bom.js +2 -1
- package/test/css/.DS_Store +0 -0
- package/test/css/functions-each.css +10 -0
- package/test/css/math/.DS_Store +0 -0
- package/test/css/namespacing/namespacing-1.css +4 -0
- package/test/css/urls.css +0 -1
- package/test/index.js +2 -5
- package/test/less/.DS_Store +0 -0
- package/test/less/colors.less +1 -1
- package/test/less/errors/color-func-invalid-color-2.less +2 -0
- package/test/less/errors/color-func-invalid-color-2.txt +3 -0
- package/test/less/functions-each.less +32 -0
- package/test/less/math/.DS_Store +0 -0
- package/test/less/namespacing/namespacing-1.less +10 -0
- package/test/less/urls.less +0 -1
- package/test/less-test.js +20 -11
- package/test/modify-vars.js +11 -2
- package/.travis.yml +0 -33
- package/appveyor.yml +0 -32
- package/browser.js +0 -1
- package/test/browser/less.js +0 -12956
- package/test/less-bom/3rd-party/bootstrap4.less +0 -1
- package/test/less-bom/3rd-party/uikit.less +0 -1
- package/test/less-bom/calc.less +0 -30
- package/test/less-bom/charsets.less +0 -3
- package/test/less-bom/colors.less +0 -116
- package/test/less-bom/comments.less +0 -102
- package/test/less-bom/comments2.less +0 -31
- package/test/less-bom/compression/compression.less +0 -36
- package/test/less-bom/css-3.less +0 -153
- package/test/less-bom/css-escapes.less +0 -42
- package/test/less-bom/css-grid.less +0 -30
- package/test/less-bom/css-guards.less +0 -103
- 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 -112
- package/test/less-bom/directives-bubling.less +0 -142
- 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/at-rules-unmatching-block.less +0 -4
- package/test/less-bom/errors/at-rules-unmatching-block.txt +0 -3
- 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/css-guard-default-func.less +0 -4
- package/test/less-bom/errors/css-guard-default-func.txt +0 -4
- package/test/less-bom/errors/custom-property-unmatched-block-1.less +0 -6
- package/test/less-bom/errors/custom-property-unmatched-block-1.txt +0 -4
- package/test/less-bom/errors/custom-property-unmatched-block-2.less +0 -6
- package/test/less-bom/errors/custom-property-unmatched-block-2.txt +0 -4
- package/test/less-bom/errors/custom-property-unmatched-block-3.less +0 -6
- package/test/less-bom/errors/custom-property-unmatched-block-3.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-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/functions-1.less +0 -2
- package/test/less-bom/errors/functions-1.txt +0 -3
- package/test/less-bom/errors/functions-10-keyword.less +0 -2
- package/test/less-bom/errors/functions-10-keyword.txt +0 -3
- package/test/less-bom/errors/functions-11-operation.less +0 -2
- package/test/less-bom/errors/functions-11-operation.txt +0 -3
- package/test/less-bom/errors/functions-12-quoted.less +0 -2
- package/test/less-bom/errors/functions-12-quoted.txt +0 -3
- package/test/less-bom/errors/functions-13-selector.less +0 -2
- package/test/less-bom/errors/functions-13-selector.txt +0 -3
- package/test/less-bom/errors/functions-14-url.less +0 -2
- package/test/less-bom/errors/functions-14-url.txt +0 -3
- package/test/less-bom/errors/functions-15-value.less +0 -2
- package/test/less-bom/errors/functions-15-value.txt +0 -3
- package/test/less-bom/errors/functions-3-assignment.less +0 -2
- package/test/less-bom/errors/functions-3-assignment.txt +0 -3
- package/test/less-bom/errors/functions-4-call.less +0 -2
- package/test/less-bom/errors/functions-4-call.txt +0 -3
- package/test/less-bom/errors/functions-5-color-2.less +0 -1
- package/test/less-bom/errors/functions-5-color-2.txt +0 -2
- package/test/less-bom/errors/functions-5-color.less +0 -2
- package/test/less-bom/errors/functions-5-color.txt +0 -3
- package/test/less-bom/errors/functions-6-condition.less +0 -2
- package/test/less-bom/errors/functions-6-condition.txt +0 -3
- package/test/less-bom/errors/functions-7-dimension.less +0 -2
- package/test/less-bom/errors/functions-7-dimension.txt +0 -3
- package/test/less-bom/errors/functions-8-element.less +0 -2
- package/test/less-bom/errors/functions-8-element.txt +0 -3
- package/test/less-bom/errors/functions-9-expression.less +0 -2
- package/test/less-bom/errors/functions-9-expression.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-2.less +0 -7
- package/test/less-bom/errors/mixin-not-defined-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-cond-expected.less +0 -5
- package/test/less-bom/errors/mixins-guards-cond-expected.txt +0 -3
- 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/namespacing-2.less +0 -7
- package/test/less-bom/errors/namespacing-2.txt +0 -4
- package/test/less-bom/errors/namespacing-3.less +0 -8
- package/test/less-bom/errors/namespacing-3.txt +0 -4
- package/test/less-bom/errors/namespacing-4.less +0 -7
- package/test/less-bom/errors/namespacing-4.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-media-no-block-1.less +0 -5
- package/test/less-bom/errors/parse-error-media-no-block-1.txt +0 -3
- package/test/less-bom/errors/parse-error-media-no-block-2.less +0 -1
- package/test/less-bom/errors/parse-error-media-no-block-2.txt +0 -2
- package/test/less-bom/errors/parse-error-media-no-block-3.less +0 -4
- package/test/less-bom/errors/parse-error-media-no-block-3.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/percentage-non-number-argument.less +0 -3
- package/test/less-bom/errors/percentage-non-number-argument.txt +0 -4
- package/test/less-bom/errors/plugin/plugin-error-2.js +0 -5
- package/test/less-bom/errors/plugin/plugin-error-3.js +0 -5
- package/test/less-bom/errors/plugin/plugin-error.js +0 -1
- package/test/less-bom/errors/plugin-1.less +0 -1
- package/test/less-bom/errors/plugin-1.txt +0 -2
- package/test/less-bom/errors/plugin-2.less +0 -1
- package/test/less-bom/errors/plugin-2.txt +0 -5
- package/test/less-bom/errors/plugin-3.less +0 -1
- package/test/less-bom/errors/plugin-3.txt +0 -5
- 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/root-func-undefined-1.less +0 -1
- package/test/less-bom/errors/root-func-undefined-1.txt +0 -2
- package/test/less-bom/errors/root-func-undefined-2.less +0 -2
- package/test/less-bom/errors/root-func-undefined-2.txt +0 -3
- 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/svg-gradient4.less +0 -4
- package/test/less-bom/errors/svg-gradient4.txt +0 -4
- package/test/less-bom/errors/svg-gradient5.less +0 -4
- package/test/less-bom/errors/svg-gradient5.txt +0 -4
- package/test/less-bom/errors/svg-gradient6.less +0 -4
- package/test/less-bom/errors/svg-gradient6.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 -110
- package/test/less-bom/extend.less +0 -81
- package/test/less-bom/extract-and-length.less +0 -146
- package/test/less-bom/filemanagerPlugin/colors.test +0 -1
- package/test/less-bom/filemanagerPlugin/filemanager.less +0 -4
- package/test/less-bom/functions-each.less +0 -131
- package/test/less-bom/functions.less +0 -279
- 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/css-import.less +0 -1
- 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-inline-invalid-css.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 -98
- package/test/less-bom/import/import-test-a.less +0 -5
- 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 -6
- 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-module.less +0 -3
- package/test/less-bom/import-once.less +0 -6
- package/test/less-bom/import-reference-issues/appender-reference-1968.less +0 -6
- package/test/less-bom/import-reference-issues/global-scope-import.less +0 -13
- package/test/less-bom/import-reference-issues/global-scope-nested.less +0 -3
- package/test/less-bom/import-reference-issues/mixin-1968.less +0 -8
- package/test/less-bom/import-reference-issues/multiple-import-nested.less +0 -12
- package/test/less-bom/import-reference-issues/multiple-import.less +0 -10
- package/test/less-bom/import-reference-issues/simple-mixin.css +0 -3
- package/test/less-bom/import-reference-issues/simple-ruleset-2162.less +0 -3
- package/test/less-bom/import-reference-issues.less +0 -50
- package/test/less-bom/import-reference.less +0 -26
- package/test/less-bom/import.less +0 -29
- package/test/less-bom/include-path/include-path.less +0 -8
- package/test/less-bom/include-path-string/include-path-string.less +0 -3
- package/test/less-bom/javascript.less +0 -39
- package/test/less-bom/lazy-eval.less +0 -6
- package/test/less-bom/legacy/legacy.less +0 -21
- package/test/less-bom/math/parens-division/media-math.less +0 -9
- package/test/less-bom/math/parens-division/mixins-args.less +0 -264
- package/test/less-bom/math/parens-division/new-division.less +0 -17
- package/test/less-bom/math/parens-division/parens.less +0 -46
- package/test/less-bom/math/strict/css.less +0 -108
- package/test/less-bom/math/strict/media-math.less +0 -9
- package/test/less-bom/math/strict/mixins-args.less +0 -264
- package/test/less-bom/math/strict/parens.less +0 -46
- package/test/less-bom/math/strict-legacy/css.less +0 -108
- package/test/less-bom/math/strict-legacy/media-math.less +0 -9
- package/test/less-bom/math/strict-legacy/mixins-args.less +0 -263
- package/test/less-bom/math/strict-legacy/parens.less +0 -50
- package/test/less-bom/media.less +0 -241
- package/test/less-bom/merge.less +0 -81
- 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 -358
- package/test/less-bom/mixins-important.less +0 -53
- 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/namespacing/imports/a-better-bootstrap.less +0 -13
- package/test/less-bom/namespacing/imports/library.less +0 -14
- package/test/less-bom/namespacing/namespacing-1.less +0 -42
- package/test/less-bom/namespacing/namespacing-2.less +0 -27
- package/test/less-bom/namespacing/namespacing-3.less +0 -28
- package/test/less-bom/namespacing/namespacing-4.less +0 -33
- package/test/less-bom/namespacing/namespacing-5.less +0 -32
- package/test/less-bom/namespacing/namespacing-6.less +0 -26
- package/test/less-bom/namespacing/namespacing-7.less +0 -48
- package/test/less-bom/namespacing/namespacing-functions.less +0 -11
- package/test/less-bom/namespacing/namespacing-media.less +0 -26
- package/test/less-bom/namespacing/namespacing-operations.less +0 -15
- 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/no-strict-math/mixins-guards.less +0 -25
- package/test/less-bom/no-strict-math/no-sm-operations.less +0 -16
- package/test/less-bom/operations.less +0 -63
- package/test/less-bom/parse-interpolation.less +0 -53
- package/test/less-bom/permissive-parse.less +0 -50
- package/test/less-bom/plugin/plugin-collection.js +0 -9
- package/test/less-bom/plugin/plugin-global.js +0 -9
- package/test/less-bom/plugin/plugin-local.js +0 -14
- package/test/less-bom/plugin/plugin-preeval.js +0 -27
- package/test/less-bom/plugin/plugin-scope1.js +0 -3
- package/test/less-bom/plugin/plugin-scope2.js +0 -3
- package/test/less-bom/plugin/plugin-set-options-v2.js +0 -33
- package/test/less-bom/plugin/plugin-set-options-v3.js +0 -31
- package/test/less-bom/plugin/plugin-set-options.js +0 -32
- package/test/less-bom/plugin/plugin-simple.js +0 -7
- package/test/less-bom/plugin/plugin-transitive.js +0 -6
- package/test/less-bom/plugin/plugin-transitive.less +0 -5
- package/test/less-bom/plugin/plugin-tree-nodes.js +0 -82
- package/test/less-bom/plugin-module.less +0 -7
- package/test/less-bom/plugin-preeval.less +0 -15
- package/test/less-bom/plugin.less +0 -142
- package/test/less-bom/postProcessorPlugin/postProcessor.less +0 -4
- package/test/less-bom/preProcessorPlugin/preProcessor.less +0 -3
- package/test/less-bom/property-accessors.less +0 -67
- package/test/less-bom/property-name-interp.less +0 -56
- package/test/less-bom/rewrite-urls-all/folder/file.less +0 -8
- package/test/less-bom/rewrite-urls-all/rewrite-urls-all.less +0 -11
- package/test/less-bom/rewrite-urls-local/folder/file.less +0 -8
- package/test/less-bom/rewrite-urls-local/rewrite-urls-local.less +0 -11
- package/test/less-bom/root-registry/file.less +0 -1
- package/test/less-bom/root-registry/root.less +0 -3
- package/test/less-bom/rootpath-rewrite-urls-all/folder/file.less +0 -8
- package/test/less-bom/rootpath-rewrite-urls-all/rootpath-rewrite-urls-all.less +0 -11
- package/test/less-bom/rootpath-rewrite-urls-local/folder/file.less +0 -8
- package/test/less-bom/rootpath-rewrite-urls-local/rootpath-rewrite-urls-local.less +0 -11
- package/test/less-bom/rulesets.less +0 -30
- package/test/less-bom/scope.less +0 -104
- package/test/less-bom/selectors.less +0 -184
- package/test/less-bom/sourcemaps/basic.json +0 -3
- package/test/less-bom/sourcemaps/basic.less +0 -27
- package/test/less-bom/sourcemaps/custom-props.less +0 -8
- package/test/less-bom/sourcemaps/imported.css +0 -7
- package/test/less-bom/sourcemaps-empty/empty.less +0 -1
- package/test/less-bom/sourcemaps-empty/var-defs.less +0 -1
- 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 -127
- package/test/less-bom/visitorPlugin/visitor.less +0 -4
- package/test/less-bom/whitespace.less +0 -44
|
@@ -1,21 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import functionRegistry from './function-registry';
|
|
2
|
+
import functionCaller from './function-caller';
|
|
3
|
+
|
|
4
|
+
import boolean from './boolean';
|
|
5
|
+
import defaultFunc from './default';
|
|
6
|
+
import color from './color';
|
|
7
|
+
import colorBlending from './color-blending';
|
|
8
|
+
import dataUri from './data-uri';
|
|
9
|
+
import list from './list';
|
|
10
|
+
import math from './math';
|
|
11
|
+
import number from './number';
|
|
12
|
+
import string from './string';
|
|
13
|
+
import svg from './svg';
|
|
14
|
+
import types from './types';
|
|
15
|
+
|
|
16
|
+
export default environment => {
|
|
17
|
+
const functions = { functionRegistry, functionCaller };
|
|
6
18
|
|
|
7
19
|
// register functions
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
functionRegistry.addMultiple(boolean);
|
|
21
|
+
functionRegistry.add('default', defaultFunc.eval.bind(defaultFunc));
|
|
22
|
+
functionRegistry.addMultiple(color);
|
|
23
|
+
functionRegistry.addMultiple(colorBlending);
|
|
24
|
+
functionRegistry.addMultiple(dataUri(environment));
|
|
25
|
+
functionRegistry.addMultiple(list);
|
|
26
|
+
functionRegistry.addMultiple(math);
|
|
27
|
+
functionRegistry.addMultiple(number);
|
|
28
|
+
functionRegistry.addMultiple(string);
|
|
29
|
+
functionRegistry.addMultiple(svg(environment));
|
|
30
|
+
functionRegistry.addMultiple(types);
|
|
19
31
|
|
|
20
32
|
return functions;
|
|
21
33
|
};
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import Comment from '../tree/comment';
|
|
2
|
+
import Dimension from '../tree/dimension';
|
|
3
|
+
import Declaration from '../tree/declaration';
|
|
4
|
+
import Expression from '../tree/expression';
|
|
5
|
+
import Ruleset from '../tree/ruleset';
|
|
6
|
+
import Selector from '../tree/selector';
|
|
7
|
+
import Element from '../tree/element';
|
|
8
|
+
import Quote from '../tree/quoted';
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
const getItemsFromNode = node => {
|
|
11
11
|
// handle non-array values as an array of length 1
|
|
12
12
|
// return 'undefined' if index is invalid
|
|
13
|
-
|
|
13
|
+
const items = Array.isArray(node.value) ?
|
|
14
14
|
node.value : Array(node);
|
|
15
15
|
|
|
16
16
|
return items;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
export default {
|
|
20
20
|
_SELF: function(n) {
|
|
21
21
|
return n;
|
|
22
22
|
},
|
|
@@ -37,7 +37,10 @@ functionRegistry.addMultiple({
|
|
|
37
37
|
* @param {Dimension} [step=1]
|
|
38
38
|
*/
|
|
39
39
|
range: function(start, end, step) {
|
|
40
|
-
|
|
40
|
+
let from;
|
|
41
|
+
let to;
|
|
42
|
+
let stepValue = 1;
|
|
43
|
+
const list = [];
|
|
41
44
|
if (end) {
|
|
42
45
|
to = end;
|
|
43
46
|
from = start.value;
|
|
@@ -50,16 +53,18 @@ functionRegistry.addMultiple({
|
|
|
50
53
|
to = start;
|
|
51
54
|
}
|
|
52
55
|
|
|
53
|
-
for (
|
|
56
|
+
for (let i = from; i <= to.value; i += stepValue) {
|
|
54
57
|
list.push(new Dimension(i, to.unit));
|
|
55
58
|
}
|
|
56
59
|
|
|
57
60
|
return new Expression(list);
|
|
58
61
|
},
|
|
59
62
|
each: function(list, rs) {
|
|
60
|
-
|
|
63
|
+
const rules = [];
|
|
64
|
+
let newRules;
|
|
65
|
+
let iterator;
|
|
61
66
|
|
|
62
|
-
if (list.value) {
|
|
67
|
+
if (list.value && !(list instanceof Quote)) {
|
|
63
68
|
if (Array.isArray(list.value)) {
|
|
64
69
|
iterator = list.value;
|
|
65
70
|
} else {
|
|
@@ -75,9 +80,9 @@ functionRegistry.addMultiple({
|
|
|
75
80
|
iterator = [list];
|
|
76
81
|
}
|
|
77
82
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
83
|
+
let valueName = '@value';
|
|
84
|
+
let keyName = '@key';
|
|
85
|
+
let indexName = '@index';
|
|
81
86
|
|
|
82
87
|
if (rs.params) {
|
|
83
88
|
valueName = rs.params[0] && rs.params[0].name;
|
|
@@ -88,8 +93,10 @@ functionRegistry.addMultiple({
|
|
|
88
93
|
rs = rs.ruleset;
|
|
89
94
|
}
|
|
90
95
|
|
|
91
|
-
for (
|
|
92
|
-
|
|
96
|
+
for (let i = 0; i < iterator.length; i++) {
|
|
97
|
+
let key;
|
|
98
|
+
let value;
|
|
99
|
+
const item = iterator[i];
|
|
93
100
|
if (item instanceof Declaration) {
|
|
94
101
|
key = typeof item.name === 'string' ? item.name : item.name[0].value;
|
|
95
102
|
value = item.value;
|
|
@@ -97,7 +104,7 @@ functionRegistry.addMultiple({
|
|
|
97
104
|
key = new Dimension(i + 1);
|
|
98
105
|
value = item;
|
|
99
106
|
}
|
|
100
|
-
|
|
107
|
+
|
|
101
108
|
if (item instanceof Comment) {
|
|
102
109
|
continue;
|
|
103
110
|
}
|
|
@@ -118,7 +125,7 @@ functionRegistry.addMultiple({
|
|
|
118
125
|
key,
|
|
119
126
|
false, false, this.index, this.currentFileInfo));
|
|
120
127
|
}
|
|
121
|
-
|
|
128
|
+
|
|
122
129
|
rules.push(new Ruleset([ new(Selector)([ new Element("", '&') ]) ],
|
|
123
130
|
newRules,
|
|
124
131
|
rs.strictImports,
|
|
@@ -127,10 +134,9 @@ functionRegistry.addMultiple({
|
|
|
127
134
|
}
|
|
128
135
|
|
|
129
136
|
return new Ruleset([ new(Selector)([ new Element("", '&') ]) ],
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
137
|
+
rules,
|
|
138
|
+
rs.strictImports,
|
|
139
|
+
rs.visibilityInfo()
|
|
140
|
+
).eval(this.context);
|
|
135
141
|
}
|
|
136
|
-
}
|
|
142
|
+
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import Dimension from '../tree/dimension';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
MathHelper._math = function (fn, unit, n) {
|
|
3
|
+
const MathHelper = (fn, unit, n) => {
|
|
6
4
|
if (!(n instanceof Dimension)) {
|
|
7
5
|
throw { type: 'Argument', message: 'argument must be a number' };
|
|
8
6
|
}
|
|
@@ -13,4 +11,5 @@ MathHelper._math = function (fn, unit, n) {
|
|
|
13
11
|
}
|
|
14
12
|
return new Dimension(fn(parseFloat(n.value)), unit);
|
|
15
13
|
};
|
|
16
|
-
|
|
14
|
+
|
|
15
|
+
export default MathHelper;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
mathHelper = require('./math-helper.js');
|
|
1
|
+
import mathHelper from './math-helper.js';
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
const mathFunctions = {
|
|
5
4
|
// name, unit
|
|
6
5
|
ceil: null,
|
|
7
6
|
floor: null,
|
|
@@ -15,15 +14,15 @@ var mathFunctions = {
|
|
|
15
14
|
acos: 'rad'
|
|
16
15
|
};
|
|
17
16
|
|
|
18
|
-
for (
|
|
17
|
+
for (const f in mathFunctions) {
|
|
19
18
|
if (mathFunctions.hasOwnProperty(f)) {
|
|
20
|
-
mathFunctions[f] = mathHelper.
|
|
19
|
+
mathFunctions[f] = mathHelper.bind(null, Math[f], mathFunctions[f]);
|
|
21
20
|
}
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
mathFunctions.round =
|
|
25
|
-
|
|
26
|
-
return mathHelper
|
|
23
|
+
mathFunctions.round = (n, f) => {
|
|
24
|
+
const fraction = typeof f === 'undefined' ? 0 : f.value;
|
|
25
|
+
return mathHelper(num => num.toFixed(fraction), null, n);
|
|
27
26
|
};
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
export default mathFunctions;
|
|
@@ -1,16 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
mathHelper = require('./math-helper.js');
|
|
1
|
+
import Dimension from '../tree/dimension';
|
|
2
|
+
import Anonymous from '../tree/anonymous';
|
|
3
|
+
import mathHelper from './math-helper.js';
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
const minMax = function (isMin, args) {
|
|
7
6
|
args = Array.prototype.slice.call(args);
|
|
8
7
|
switch (args.length) {
|
|
9
8
|
case 0: throw { type: 'Argument', message: 'one or more arguments required' };
|
|
10
9
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
let i; // key is the unit.toString() for unified Dimension values,
|
|
11
|
+
let j;
|
|
12
|
+
let current;
|
|
13
|
+
let currentUnified;
|
|
14
|
+
let referenceUnified;
|
|
15
|
+
let unit;
|
|
16
|
+
let unitStatic;
|
|
17
|
+
let unitClone;
|
|
18
|
+
|
|
19
|
+
const // elems only contains original argument values.
|
|
20
|
+
order = [];
|
|
21
|
+
|
|
22
|
+
const values = {};
|
|
14
23
|
// value is the index into the order array.
|
|
15
24
|
for (i = 0; i < args.length; i++) {
|
|
16
25
|
current = args[i];
|
|
@@ -43,14 +52,15 @@ var minMax = function (isMin, args) {
|
|
|
43
52
|
return order[0];
|
|
44
53
|
}
|
|
45
54
|
args = order.map(function (a) { return a.toCSS(this.context); }).join(this.context.compress ? ',' : ', ');
|
|
46
|
-
return new Anonymous(
|
|
55
|
+
return new Anonymous(`${isMin ? 'min' : 'max'}(${args})`);
|
|
47
56
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
57
|
+
|
|
58
|
+
export default {
|
|
59
|
+
min: function(...args) {
|
|
60
|
+
return minMax(true, args);
|
|
51
61
|
},
|
|
52
|
-
max: function
|
|
53
|
-
return minMax(false,
|
|
62
|
+
max: function(...args) {
|
|
63
|
+
return minMax(false, args);
|
|
54
64
|
},
|
|
55
65
|
convert: function (val, unit) {
|
|
56
66
|
return val.convertTo(unit.value);
|
|
@@ -72,10 +82,8 @@ functionRegistry.addMultiple({
|
|
|
72
82
|
return new Dimension(Math.pow(x.value, y.value), x.unit);
|
|
73
83
|
},
|
|
74
84
|
percentage: function (n) {
|
|
75
|
-
|
|
76
|
-
return num * 100;
|
|
77
|
-
}, '%', n);
|
|
85
|
+
const result = mathHelper(num => num * 100, '%', n);
|
|
78
86
|
|
|
79
87
|
return result;
|
|
80
88
|
}
|
|
81
|
-
}
|
|
89
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import Quoted from '../tree/quoted';
|
|
2
|
+
import Anonymous from '../tree/anonymous';
|
|
3
|
+
import Quote from '../tree/quoted';
|
|
4
|
+
import JavaScript from '../tree/javascript';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
export default {
|
|
7
7
|
e: function (str) {
|
|
8
|
-
return new
|
|
8
|
+
return new Quote('"', str instanceof JavaScript ? str.evaluated : str.value, true);
|
|
9
9
|
},
|
|
10
10
|
escape: function (str) {
|
|
11
11
|
return new Anonymous(
|
|
@@ -13,20 +13,20 @@ functionRegistry.addMultiple({
|
|
|
13
13
|
.replace(/\(/g, '%28').replace(/\)/g, '%29'));
|
|
14
14
|
},
|
|
15
15
|
replace: function (string, pattern, replacement, flags) {
|
|
16
|
-
|
|
16
|
+
let result = string.value;
|
|
17
17
|
replacement = (replacement.type === 'Quoted') ?
|
|
18
18
|
replacement.value : replacement.toCSS();
|
|
19
19
|
result = result.replace(new RegExp(pattern.value, flags ? flags.value : ''), replacement);
|
|
20
20
|
return new Quoted(string.quote || '', result, string.escaped);
|
|
21
21
|
},
|
|
22
22
|
'%': function (string /* arg, arg, ... */) {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
const args = Array.prototype.slice.call(arguments, 1);
|
|
24
|
+
let result = string.value;
|
|
25
25
|
|
|
26
|
-
for (
|
|
26
|
+
for (let i = 0; i < args.length; i++) {
|
|
27
27
|
/* jshint loopfunc:true */
|
|
28
|
-
result = result.replace(/%[sda]/i,
|
|
29
|
-
|
|
28
|
+
result = result.replace(/%[sda]/i, token => {
|
|
29
|
+
const value = ((args[i].type === 'Quoted') &&
|
|
30
30
|
token.match(/s/i)) ? args[i].value : args[i].toCSS();
|
|
31
31
|
return token.match(/[A-Z]$/) ? encodeURIComponent(value) : value;
|
|
32
32
|
});
|
|
@@ -34,4 +34,4 @@ functionRegistry.addMultiple({
|
|
|
34
34
|
result = result.replace(/%%/g, '%');
|
|
35
35
|
return new Quoted(string.quote || '', result, string.escaped);
|
|
36
36
|
}
|
|
37
|
-
}
|
|
37
|
+
};
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
URL = require('../tree/url'),
|
|
7
|
-
functionRegistry = require('./function-registry');
|
|
1
|
+
import Dimension from '../tree/dimension';
|
|
2
|
+
import Color from '../tree/color';
|
|
3
|
+
import Expression from '../tree/expression';
|
|
4
|
+
import Quoted from '../tree/quoted';
|
|
5
|
+
import URL from '../tree/url';
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
export default environment => {
|
|
8
|
+
return { 'svg-gradient': function(direction) {
|
|
9
|
+
let stops;
|
|
10
|
+
let gradientDirectionSvg;
|
|
11
|
+
let gradientType = 'linear';
|
|
12
|
+
let rectangleDimension = 'x="0" y="0" width="1" height="1"';
|
|
13
|
+
const renderEnv = {compress: false};
|
|
14
|
+
let returner;
|
|
15
|
+
const directionValue = direction.toCSS(renderEnv);
|
|
16
|
+
let i;
|
|
17
|
+
let color;
|
|
18
|
+
let position;
|
|
19
|
+
let positionValue;
|
|
20
|
+
let alpha;
|
|
19
21
|
|
|
20
22
|
function throwArgumentDescriptor() {
|
|
21
23
|
throw { type: 'Argument',
|
|
@@ -57,8 +59,7 @@ module.exports = function(environment) {
|
|
|
57
59
|
throw { type: 'Argument', message: 'svg-gradient direction must be \'to bottom\', \'to right\',' +
|
|
58
60
|
' \'to bottom right\', \'to top right\' or \'ellipse at center\'' };
|
|
59
61
|
}
|
|
60
|
-
returner =
|
|
61
|
-
'<' + gradientType + 'Gradient id="g" ' + gradientDirectionSvg + '>';
|
|
62
|
+
returner = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1 1"><${gradientType}Gradient id="g" ${gradientDirectionSvg}>`;
|
|
62
63
|
|
|
63
64
|
for (i = 0; i < stops.length; i += 1) {
|
|
64
65
|
if (stops[i] instanceof Expression) {
|
|
@@ -74,14 +75,13 @@ module.exports = function(environment) {
|
|
|
74
75
|
}
|
|
75
76
|
positionValue = position ? position.toCSS(renderEnv) : i === 0 ? '0%' : '100%';
|
|
76
77
|
alpha = color.alpha;
|
|
77
|
-
returner +=
|
|
78
|
+
returner += `<stop offset="${positionValue}" stop-color="${color.toRGB()}"${alpha < 1 ? ` stop-opacity="${alpha}"` : ''}/>`;
|
|
78
79
|
}
|
|
79
|
-
returner +=
|
|
80
|
-
'<rect ' + rectangleDimension + ' fill="url(#g)" /></svg>';
|
|
80
|
+
returner += `</${gradientType}Gradient><rect ${rectangleDimension} fill="url(#g)" /></svg>`;
|
|
81
81
|
|
|
82
82
|
returner = encodeURIComponent(returner);
|
|
83
83
|
|
|
84
|
-
returner =
|
|
85
|
-
return new URL(new Quoted('
|
|
86
|
-
}
|
|
84
|
+
returner = `data:image/svg+xml,${returner}`;
|
|
85
|
+
return new URL(new Quoted(`'${returner}'`, returner, false, this.index, this.currentFileInfo), this.index, this.currentFileInfo);
|
|
86
|
+
}};
|
|
87
87
|
};
|
|
@@ -1,28 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
functionRegistry = require('./function-registry');
|
|
1
|
+
import Keyword from '../tree/keyword';
|
|
2
|
+
import DetachedRuleset from '../tree/detached-ruleset';
|
|
3
|
+
import Dimension from '../tree/dimension';
|
|
4
|
+
import Color from '../tree/color';
|
|
5
|
+
import Quoted from '../tree/quoted';
|
|
6
|
+
import Anonymous from '../tree/anonymous';
|
|
7
|
+
import URL from '../tree/url';
|
|
8
|
+
import Operation from '../tree/operation';
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return (n instanceof Dimension) && n.unit.is(unit) ? Keyword.True : Keyword.False;
|
|
23
|
-
};
|
|
10
|
+
const isa = (n, Type) => (n instanceof Type) ? Keyword.True : Keyword.False;
|
|
11
|
+
const isunit = (n, unit) => {
|
|
12
|
+
if (unit === undefined) {
|
|
13
|
+
throw { type: 'Argument', message: 'missing the required second argument to isunit.' };
|
|
14
|
+
}
|
|
15
|
+
unit = typeof unit.value === 'string' ? unit.value : unit;
|
|
16
|
+
if (typeof unit !== 'string') {
|
|
17
|
+
throw { type: 'Argument', message: 'Second argument to isunit should be a unit or a string.' };
|
|
18
|
+
}
|
|
19
|
+
return (n instanceof Dimension) && n.unit.is(unit) ? Keyword.True : Keyword.False;
|
|
20
|
+
};
|
|
24
21
|
|
|
25
|
-
|
|
22
|
+
export default {
|
|
26
23
|
isruleset: function (n) {
|
|
27
24
|
return isa(n, DetachedRuleset);
|
|
28
25
|
},
|
|
@@ -50,12 +47,11 @@ functionRegistry.addMultiple({
|
|
|
50
47
|
isem: function (n) {
|
|
51
48
|
return isunit(n, 'em');
|
|
52
49
|
},
|
|
53
|
-
isunit
|
|
50
|
+
isunit,
|
|
54
51
|
unit: function (val, unit) {
|
|
55
52
|
if (!(val instanceof Dimension)) {
|
|
56
53
|
throw { type: 'Argument',
|
|
57
|
-
message:
|
|
58
|
-
(val instanceof Operation ? '. Have you forgotten parenthesis?' : '') };
|
|
54
|
+
message: `the first argument to unit must be a number${val instanceof Operation ? '. Have you forgotten parenthesis?' : ''}` };
|
|
59
55
|
}
|
|
60
56
|
if (unit) {
|
|
61
57
|
if (unit instanceof Keyword) {
|
|
@@ -71,4 +67,4 @@ functionRegistry.addMultiple({
|
|
|
71
67
|
'get-unit': function (n) {
|
|
72
68
|
return new Anonymous(n.unit);
|
|
73
69
|
}
|
|
74
|
-
}
|
|
70
|
+
};
|