less 2.2.2 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Changelog.md +17 -0
- data/Gemfile +7 -3
- data/README.md +29 -13
- data/bin/lessc +3 -1
- data/less.gemspec +2 -6
- data/lib/less/defaults.rb +3 -3
- data/lib/less/java_script/rhino_context.rb +17 -27
- data/lib/less/java_script/v8_context.rb +11 -11
- data/lib/less/js/.gitattributes +10 -0
- data/lib/less/js/.gitignore +24 -0
- data/lib/less/js/.jshintrc +11 -0
- data/lib/less/js/.npmignore +1 -0
- data/lib/less/js/.travis.yml +8 -0
- data/lib/less/js/CHANGELOG.md +299 -0
- data/lib/less/js/CONTRIBUTING.md +50 -0
- data/lib/less/js/Gruntfile.js +298 -0
- data/lib/less/js/README.md +43 -12
- data/lib/less/js/benchmark/benchmark.less +194 -194
- data/lib/less/js/benchmark/less-benchmark.js +9 -10
- data/lib/less/js/bin/lessc +310 -37
- data/lib/less/js/bower.json +18 -0
- data/lib/less/js/build/README.md +51 -0
- data/lib/less/js/build/amd.js +1 -1
- data/lib/less/js/build/browser-header.js +4 -0
- data/lib/less/js/build/build.yml +162 -0
- data/lib/less/js/build/require-rhino.js +7 -2
- data/lib/less/js/build/rhino-header.js +4 -0
- data/lib/less/js/build/rhino-modules.js +131 -0
- data/lib/less/js/build/tasks/.gitkeep +1 -0
- data/lib/less/js/build.gradle +347 -0
- data/lib/less/js/dist/less-1.3.1.js +4011 -0
- data/lib/less/js/dist/less-1.3.1.min.js +9 -0
- data/lib/less/js/dist/less-1.3.2.js +4401 -0
- data/lib/less/js/dist/less-1.3.2.min.js +9 -0
- data/lib/less/js/dist/less-1.3.3.js +4413 -0
- data/lib/less/js/dist/less-1.3.3.min.js +9 -0
- data/lib/less/js/dist/less-1.4.0-beta.js +5830 -0
- data/lib/less/js/dist/less-1.4.0-beta.min.js +11 -0
- data/lib/less/js/dist/less-1.4.0.js +5830 -0
- data/lib/less/js/dist/less-1.4.0.min.js +11 -0
- data/lib/less/js/dist/less-1.4.1.js +5837 -0
- data/lib/less/js/dist/less-1.4.1.min.js +11 -0
- data/lib/less/js/dist/less-1.4.2.js +5837 -0
- data/lib/less/js/dist/less-1.4.2.min.js +11 -0
- data/lib/less/js/dist/less-1.5.0.js +6914 -0
- data/lib/less/js/dist/less-1.5.0.min.js +13 -0
- data/lib/less/js/dist/less-1.5.1.js +6941 -0
- data/lib/less/js/dist/less-1.5.1.min.js +13 -0
- data/lib/less/js/dist/less-1.6.0.js +7485 -0
- data/lib/less/js/dist/less-1.6.0.min.js +16 -0
- data/lib/less/js/dist/less-1.6.1.js +7513 -0
- data/lib/less/js/dist/less-1.6.1.min.js +16 -0
- data/lib/less/js/dist/less-1.6.2.js +7624 -0
- data/lib/less/js/dist/less-1.6.2.min.js +16 -0
- data/lib/less/js/dist/less-1.6.3.js +7627 -0
- data/lib/less/js/dist/less-1.6.3.min.js +16 -0
- data/lib/less/js/dist/less-1.7.0.js +7921 -0
- data/lib/less/js/dist/less-1.7.0.min.js +16 -0
- data/lib/less/js/dist/less-rhino-1.3.1.js +3725 -0
- data/lib/less/js/dist/less-rhino-1.3.2.js +3990 -0
- data/lib/less/js/dist/less-rhino-1.3.3.js +4002 -0
- data/lib/less/js/dist/less-rhino-1.4.0.js +4273 -0
- data/lib/less/js/dist/less-rhino-1.5.1.js +6831 -0
- data/lib/less/js/dist/less-rhino-1.6.2.js +9017 -0
- data/lib/less/js/dist/less-rhino-1.6.3.js +9020 -0
- data/lib/less/js/dist/less-rhino-1.7.0.js +9301 -0
- data/lib/less/js/dist/lessc-rhino-1.6.2.js +449 -0
- data/lib/less/js/dist/lessc-rhino-1.6.3.js +449 -0
- data/lib/less/js/dist/lessc-rhino-1.7.0.js +449 -0
- data/lib/less/js/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/lib/less/js/gradle/wrapper/gradle-wrapper.properties +6 -0
- data/lib/less/js/gradlew +164 -0
- data/lib/less/js/gradlew.bat +90 -0
- data/lib/less/js/lib/less/browser.js +547 -250
- data/lib/less/js/lib/less/encoder.js +4 -0
- data/lib/less/js/lib/less/env.js +136 -0
- data/lib/less/js/lib/less/extend-visitor.js +416 -0
- data/lib/less/js/lib/less/functions.js +576 -36
- data/lib/less/js/lib/less/import-visitor.js +142 -0
- data/lib/less/js/lib/less/index.js +187 -83
- data/lib/less/js/lib/less/join-selector-visitor.js +44 -0
- data/lib/less/js/lib/less/lessc_helper.js +82 -0
- data/lib/less/js/lib/less/parser.js +1286 -523
- data/lib/less/js/lib/less/rhino.js +415 -29
- data/lib/less/js/lib/less/source-map-output.js +141 -0
- data/lib/less/js/lib/less/to-css-visitor.js +240 -0
- data/lib/less/js/lib/less/tree/alpha.js +17 -5
- data/lib/less/js/lib/less/tree/anonymous.js +25 -4
- data/lib/less/js/lib/less/tree/assignment.js +17 -5
- data/lib/less/js/lib/less/tree/call.js +36 -13
- data/lib/less/js/lib/less/tree/color.js +119 -31
- data/lib/less/js/lib/less/tree/comment.js +18 -4
- data/lib/less/js/lib/less/tree/condition.js +35 -28
- data/lib/less/js/lib/less/tree/detached-ruleset.js +20 -0
- data/lib/less/js/lib/less/tree/dimension.js +291 -16
- data/lib/less/js/lib/less/tree/directive.js +56 -22
- data/lib/less/js/lib/less/tree/element.js +78 -17
- data/lib/less/js/lib/less/tree/expression.js +39 -8
- data/lib/less/js/lib/less/tree/extend.js +53 -0
- data/lib/less/js/lib/less/tree/import.js +81 -36
- data/lib/less/js/lib/less/tree/javascript.js +17 -10
- data/lib/less/js/lib/less/tree/keyword.js +8 -3
- data/lib/less/js/lib/less/tree/media.js +70 -27
- data/lib/less/js/lib/less/tree/mixin.js +250 -70
- data/lib/less/js/lib/less/tree/negative.js +24 -0
- data/lib/less/js/lib/less/tree/operation.js +38 -13
- data/lib/less/js/lib/less/tree/paren.js +9 -2
- data/lib/less/js/lib/less/tree/quoted.js +29 -10
- data/lib/less/js/lib/less/tree/rule.js +77 -29
- data/lib/less/js/lib/less/tree/ruleset-call.js +16 -0
- data/lib/less/js/lib/less/tree/ruleset.js +445 -107
- data/lib/less/js/lib/less/tree/selector.js +117 -30
- data/lib/less/js/lib/less/tree/unicode-descriptor.js +15 -0
- data/lib/less/js/lib/less/tree/url.js +43 -15
- data/lib/less/js/lib/less/tree/value.js +16 -6
- data/lib/less/js/lib/less/tree/variable.js +26 -8
- data/lib/less/js/lib/less/tree.js +82 -2
- data/lib/less/js/lib/less/visitor.js +146 -0
- data/lib/less/js/lib/source-map/source-map-0.1.31.js +1933 -0
- data/lib/less/js/lib/source-map/source-map-footer.js +4 -0
- data/lib/less/js/lib/source-map/source-map-header.js +3 -0
- data/lib/less/js/package.json +86 -11
- data/lib/less/js/test/browser/common.js +201 -0
- data/lib/less/js/test/browser/css/global-vars/simple.css +3 -0
- data/lib/less/js/test/browser/css/modify-vars/simple.css +8 -0
- data/lib/less/js/test/browser/css/postProcessor/postProcessor.css +4 -0
- data/lib/less/js/test/browser/css/relative-urls/urls.css +35 -0
- data/lib/less/js/test/browser/css/rootpath/urls.css +35 -0
- data/lib/less/js/test/browser/css/rootpath-relative/urls.css +35 -0
- data/lib/less/js/test/browser/css/urls.css +53 -0
- data/lib/less/js/test/browser/es5.js +27 -0
- data/lib/less/js/test/browser/jasmine-html.js +681 -0
- data/lib/less/js/test/browser/jasmine.css +82 -0
- data/lib/less/js/test/browser/jasmine.js +2600 -0
- data/lib/less/js/test/browser/less/console-errors/test-error.less +3 -0
- data/lib/less/js/test/browser/less/console-errors/test-error.txt +2 -0
- data/lib/less/js/test/browser/less/global-vars/simple.less +3 -0
- data/lib/less/js/test/browser/less/imports/urls.less +4 -0
- data/lib/less/js/test/browser/less/imports/urls2.less +4 -0
- data/lib/less/js/test/browser/less/modify-vars/imports/simple2.less +4 -0
- data/lib/less/js/test/browser/less/modify-vars/simple.less +8 -0
- data/lib/less/js/test/browser/less/postProcessor/postProcessor.less +4 -0
- data/lib/less/js/test/browser/less/relative-urls/urls.less +33 -0
- data/lib/less/js/test/browser/less/rootpath/urls.less +33 -0
- data/lib/less/js/test/browser/less/rootpath-relative/urls.less +33 -0
- data/lib/less/js/test/browser/less/urls.less +57 -0
- data/lib/less/js/test/browser/phantom-runner.js +150 -0
- data/lib/less/js/test/browser/runner-browser-options.js +42 -0
- data/lib/less/js/test/browser/runner-browser-spec.js +12 -0
- data/lib/less/js/test/browser/runner-console-errors.js +5 -0
- data/lib/less/js/test/browser/runner-errors-options.js +5 -0
- data/lib/less/js/test/browser/runner-errors-spec.js +4 -0
- data/lib/less/js/test/browser/runner-global-vars-options.js +4 -0
- data/lib/less/js/test/browser/runner-global-vars-spec.js +3 -0
- data/lib/less/js/test/browser/runner-legacy-options.js +4 -0
- data/lib/less/js/test/browser/runner-legacy-spec.js +3 -0
- data/lib/less/js/test/browser/runner-main-options.js +15 -0
- data/lib/less/js/test/browser/runner-main-spec.js +3 -0
- data/lib/less/js/test/browser/runner-modify-vars-options.js +2 -0
- data/lib/less/js/test/browser/runner-modify-vars-spec.js +43 -0
- data/lib/less/js/test/browser/runner-no-js-errors-options.js +4 -0
- data/lib/less/js/test/browser/runner-no-js-errors-spec.js +4 -0
- data/lib/less/js/test/browser/runner-postProcessor-options.js +4 -0
- data/lib/less/js/test/browser/runner-postProcessor.js +3 -0
- data/lib/less/js/test/browser/runner-production-options.js +3 -0
- data/lib/less/js/test/browser/runner-production-spec.js +5 -0
- data/lib/less/js/test/browser/runner-relative-urls-options.js +3 -0
- data/lib/less/js/test/browser/runner-relative-urls-spec.js +3 -0
- data/lib/less/js/test/browser/runner-rootpath-options.js +3 -0
- data/lib/less/js/test/browser/runner-rootpath-relative-options.js +4 -0
- data/lib/less/js/test/browser/runner-rootpath-relative-spec.js +3 -0
- data/lib/less/js/test/browser/runner-rootpath-spec.js +3 -0
- data/lib/less/js/test/browser/test-runner-template.tmpl +47 -0
- data/lib/less/js/test/css/charsets.css +1 -0
- data/lib/less/js/test/css/colors.css +29 -0
- data/lib/less/js/test/css/comments.css +15 -2
- data/lib/less/js/test/css/compression/compression.css +3 -0
- data/lib/less/js/test/css/css-3.css +73 -2
- data/lib/less/js/test/css/css-escapes.css +4 -0
- data/lib/less/js/test/css/css-guards.css +37 -0
- data/lib/less/js/test/css/css.css +20 -14
- data/lib/less/js/test/css/debug/linenumbers-all.css +49 -0
- data/lib/less/js/test/css/debug/linenumbers-comments.css +40 -0
- data/lib/less/js/test/css/debug/linenumbers-mediaquery.css +40 -0
- data/lib/less/js/test/css/detached-rulesets.css +71 -0
- data/lib/less/js/test/css/empty.css +0 -0
- data/lib/less/js/test/css/extend-chaining.css +81 -0
- data/lib/less/js/test/css/extend-clearfix.css +19 -0
- data/lib/less/js/test/css/extend-exact.css +37 -0
- data/lib/less/js/test/css/extend-media.css +24 -0
- data/lib/less/js/test/css/extend-nest.css +57 -0
- data/lib/less/js/test/css/extend-selector.css +80 -0
- data/lib/less/js/test/css/extend.css +76 -0
- data/lib/less/js/test/css/extract-and-length.css +133 -0
- data/lib/less/js/test/css/functions.css +117 -2
- data/lib/less/js/test/css/globalVars/extended.css +12 -0
- data/lib/less/js/test/css/globalVars/simple.css +6 -0
- data/lib/less/js/test/css/ie-filters.css +7 -3
- data/lib/less/js/test/css/import-inline.css +5 -0
- data/lib/less/js/test/css/import-interpolation.css +6 -0
- data/lib/less/js/test/css/import-once.css +15 -0
- data/lib/less/js/test/css/import-reference.css +68 -0
- data/lib/less/js/test/css/import.css +23 -10
- data/lib/less/js/test/css/javascript.css +3 -2
- data/lib/less/js/test/css/legacy/legacy.css +7 -0
- data/lib/less/js/test/css/media.css +141 -1
- data/lib/less/js/test/css/merge.css +34 -0
- data/lib/less/js/test/css/mixins-args.css +41 -4
- data/lib/less/js/test/css/mixins-guards-default-func.css +129 -0
- data/lib/less/js/test/css/mixins-guards.css +24 -0
- data/lib/less/js/test/css/mixins-important.css +28 -0
- data/lib/less/js/test/css/mixins-interpolated.css +39 -0
- data/lib/less/js/test/css/mixins-named-args.css +27 -0
- data/lib/less/js/test/css/mixins-pattern.css +4 -0
- data/lib/less/js/test/css/mixins.css +70 -0
- data/lib/less/js/test/css/modifyVars/extended.css +9 -0
- data/lib/less/js/test/css/no-output.css +0 -0
- data/lib/less/js/test/css/parens.css +21 -5
- data/lib/less/js/test/css/property-name-interp.css +20 -0
- data/lib/less/js/test/css/scope.css +23 -0
- data/lib/less/js/test/css/selectors.css +84 -0
- data/lib/less/js/test/css/static-urls/urls.css +45 -0
- data/lib/less/js/test/css/strings.css +5 -2
- data/lib/less/js/test/css/url-args/urls.css +56 -0
- data/lib/less/js/test/css/urls.css +71 -0
- data/lib/less/js/test/css/variables-in-at-rules.css +18 -0
- data/lib/less/js/test/css/variables.css +22 -4
- data/lib/less/js/test/css/whitespace.css +4 -0
- data/lib/less/js/test/data/data-uri-fail.png +0 -0
- data/lib/less/js/test/data/image.jpg +1 -0
- data/lib/less/js/test/data/page.html +1 -0
- data/lib/less/js/test/index.js +45 -0
- data/lib/less/js/test/less/charsets.less +3 -0
- data/lib/less/js/test/less/colors.less +37 -4
- data/lib/less/js/test/less/comments.less +21 -3
- data/lib/less/js/test/less/compression/compression.less +36 -0
- data/lib/less/js/test/less/css-3.less +70 -6
- data/lib/less/js/test/less/css-escapes.less +6 -1
- data/lib/less/js/test/less/css-guards.less +102 -0
- data/lib/less/js/test/less/css.less +23 -15
- data/lib/less/js/test/less/debug/import/test.less +25 -0
- data/lib/less/js/test/less/debug/linenumbers.less +33 -0
- data/lib/less/js/test/less/detached-rulesets.less +103 -0
- data/lib/less/js/test/less/empty.less +0 -0
- data/lib/less/js/test/less/errors/add-mixed-units.less +3 -0
- data/lib/less/js/test/less/errors/add-mixed-units.txt +4 -0
- data/lib/less/js/test/less/errors/add-mixed-units2.less +3 -0
- data/lib/less/js/test/less/errors/add-mixed-units2.txt +4 -0
- data/lib/less/js/test/less/errors/at-rules-undefined-var.less +4 -0
- data/lib/less/js/test/less/errors/at-rules-undefined-var.txt +4 -0
- data/lib/less/js/test/less/errors/bad-variable-declaration1.less +1 -0
- data/lib/less/js/test/less/errors/bad-variable-declaration1.txt +2 -0
- data/lib/less/js/test/less/errors/color-func-invalid-color.less +3 -0
- data/lib/less/js/test/less/errors/color-func-invalid-color.txt +4 -0
- data/lib/less/js/test/less/errors/comment-in-selector.less +1 -0
- data/lib/less/js/test/less/errors/comment-in-selector.txt +2 -0
- data/lib/less/js/test/less/errors/css-guard-default-func.less +4 -0
- data/lib/less/js/test/less/errors/css-guard-default-func.txt +4 -0
- data/lib/less/js/test/less/errors/detached-ruleset-1.less +6 -0
- data/lib/less/js/test/less/errors/detached-ruleset-1.txt +4 -0
- data/lib/less/js/test/less/errors/detached-ruleset-2.less +6 -0
- data/lib/less/js/test/less/errors/detached-ruleset-2.txt +4 -0
- data/lib/less/js/test/less/errors/detached-ruleset-3.less +4 -0
- data/lib/less/js/test/less/errors/detached-ruleset-3.txt +4 -0
- data/lib/less/js/test/less/errors/detached-ruleset-4.less +5 -0
- data/lib/less/js/test/less/errors/detached-ruleset-4.txt +3 -0
- data/lib/less/js/test/less/errors/detached-ruleset-5.less +4 -0
- data/lib/less/js/test/less/errors/detached-ruleset-5.txt +3 -0
- data/lib/less/js/test/less/errors/detached-ruleset-6.less +5 -0
- data/lib/less/js/test/less/errors/detached-ruleset-6.txt +4 -0
- data/lib/less/js/test/less/errors/divide-mixed-units.less +3 -0
- data/lib/less/js/test/less/errors/divide-mixed-units.txt +4 -0
- data/lib/less/js/test/less/errors/extend-no-selector.less +3 -0
- data/lib/less/js/test/less/errors/extend-no-selector.txt +3 -0
- data/lib/less/js/test/less/errors/extend-not-at-end.less +3 -0
- data/lib/less/js/test/less/errors/extend-not-at-end.txt +3 -0
- data/lib/less/js/test/less/errors/import-missing.less +6 -0
- data/lib/less/js/test/less/errors/import-missing.txt +3 -0
- data/lib/less/js/test/less/errors/import-no-semi.less +1 -0
- data/lib/less/js/test/less/errors/import-no-semi.txt +2 -0
- data/lib/less/js/test/less/errors/import-subfolder1.less +1 -0
- data/lib/less/js/test/less/errors/import-subfolder1.txt +3 -0
- data/lib/less/js/test/less/errors/import-subfolder2.less +1 -0
- data/lib/less/js/test/less/errors/import-subfolder2.txt +4 -0
- data/lib/less/js/test/less/errors/imports/import-subfolder1.less +1 -0
- data/lib/less/js/test/less/errors/imports/import-subfolder2.less +1 -0
- data/lib/less/js/test/less/errors/imports/import-test.less +4 -0
- data/lib/less/js/test/less/errors/imports/subfolder/mixin-not-defined.less +1 -0
- data/lib/less/js/test/less/errors/imports/subfolder/parse-error-curly-bracket.less +1 -0
- data/lib/less/js/test/less/errors/javascript-error.less +3 -0
- data/lib/less/js/test/less/errors/javascript-error.txt +4 -0
- data/lib/less/js/test/less/errors/javascript-undefined-var.less +3 -0
- data/lib/less/js/test/less/errors/javascript-undefined-var.txt +4 -0
- data/lib/less/js/test/less/errors/mixed-mixin-definition-args-1.less +6 -0
- data/lib/less/js/test/less/errors/mixed-mixin-definition-args-1.txt +4 -0
- data/lib/less/js/test/less/errors/mixed-mixin-definition-args-2.less +6 -0
- data/lib/less/js/test/less/errors/mixed-mixin-definition-args-2.txt +4 -0
- data/lib/less/js/test/less/errors/mixin-not-defined.less +11 -0
- data/lib/less/js/test/less/errors/mixin-not-defined.txt +3 -0
- data/lib/less/js/test/less/errors/mixin-not-matched.less +6 -0
- data/lib/less/js/test/less/errors/mixin-not-matched.txt +3 -0
- data/lib/less/js/test/less/errors/mixin-not-matched2.less +6 -0
- data/lib/less/js/test/less/errors/mixin-not-matched2.txt +3 -0
- data/lib/less/js/test/less/errors/mixin-not-visible-in-scope-1.less +9 -0
- data/lib/less/js/test/less/errors/mixin-not-visible-in-scope-1.txt +4 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-1.less +9 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-1.txt +4 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-2.less +9 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-2.txt +4 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-3.less +9 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-3.txt +4 -0
- data/lib/less/js/test/less/errors/multiple-guards-on-css-selectors.less +4 -0
- data/lib/less/js/test/less/errors/multiple-guards-on-css-selectors.txt +4 -0
- data/lib/less/js/test/less/errors/multiple-guards-on-css-selectors2.less +4 -0
- data/lib/less/js/test/less/errors/multiple-guards-on-css-selectors2.txt +4 -0
- data/lib/less/js/test/less/errors/multiply-mixed-units.less +7 -0
- data/lib/less/js/test/less/errors/multiply-mixed-units.txt +4 -0
- data/lib/less/js/test/less/errors/parens-error-1.less +3 -0
- data/lib/less/js/test/less/errors/parens-error-1.txt +4 -0
- data/lib/less/js/test/less/errors/parens-error-2.less +3 -0
- data/lib/less/js/test/less/errors/parens-error-2.txt +4 -0
- data/lib/less/js/test/less/errors/parens-error-3.less +3 -0
- data/lib/less/js/test/less/errors/parens-error-3.txt +4 -0
- data/lib/less/js/test/less/errors/parse-error-curly-bracket.less +4 -0
- data/lib/less/js/test/less/errors/parse-error-curly-bracket.txt +4 -0
- data/lib/less/js/test/less/errors/parse-error-extra-parens.less +5 -0
- data/lib/less/js/test/less/errors/parse-error-extra-parens.txt +3 -0
- data/lib/less/js/test/less/errors/parse-error-missing-bracket.less +2 -0
- data/lib/less/js/test/less/errors/parse-error-missing-bracket.txt +3 -0
- data/lib/less/js/test/less/errors/parse-error-missing-parens.less +5 -0
- data/lib/less/js/test/less/errors/parse-error-missing-parens.txt +3 -0
- data/lib/less/js/test/less/errors/parse-error-with-import.less +13 -0
- data/lib/less/js/test/less/errors/parse-error-with-import.txt +4 -0
- data/lib/less/js/test/less/errors/percentage-missing-space.less +3 -0
- data/lib/less/js/test/less/errors/percentage-missing-space.txt +4 -0
- data/lib/less/js/test/less/errors/property-asterisk-only-name.less +3 -0
- data/lib/less/js/test/less/errors/property-asterisk-only-name.txt +4 -0
- data/lib/less/js/test/less/errors/property-ie5-hack.less +3 -0
- data/lib/less/js/test/less/errors/property-ie5-hack.txt +4 -0
- data/lib/less/js/test/less/errors/property-in-root.less +4 -0
- data/lib/less/js/test/less/errors/property-in-root.txt +4 -0
- data/lib/less/js/test/less/errors/property-in-root2.less +1 -0
- data/lib/less/js/test/less/errors/property-in-root2.txt +4 -0
- data/lib/less/js/test/less/errors/property-in-root3.less +4 -0
- data/lib/less/js/test/less/errors/property-in-root3.txt +3 -0
- data/lib/less/js/test/less/errors/property-interp-not-defined.less +1 -0
- data/lib/less/js/test/less/errors/property-interp-not-defined.txt +2 -0
- data/lib/less/js/test/less/errors/recursive-variable.less +1 -0
- data/lib/less/js/test/less/errors/recursive-variable.txt +2 -0
- data/lib/less/js/test/less/errors/svg-gradient1.less +3 -0
- data/lib/less/js/test/less/errors/svg-gradient1.txt +4 -0
- data/lib/less/js/test/less/errors/svg-gradient2.less +3 -0
- data/lib/less/js/test/less/errors/svg-gradient2.txt +4 -0
- data/lib/less/js/test/less/errors/svg-gradient3.less +3 -0
- data/lib/less/js/test/less/errors/svg-gradient3.txt +4 -0
- data/lib/less/js/test/less/errors/unit-function.less +3 -0
- data/lib/less/js/test/less/errors/unit-function.txt +4 -0
- data/lib/less/js/test/less/extend-chaining.less +91 -0
- data/lib/less/js/test/less/extend-clearfix.less +19 -0
- data/lib/less/js/test/less/extend-exact.less +46 -0
- data/lib/less/js/test/less/extend-media.less +24 -0
- data/lib/less/js/test/less/extend-nest.less +65 -0
- data/lib/less/js/test/less/extend-selector.less +99 -0
- data/lib/less/js/test/less/extend.less +81 -0
- data/lib/less/js/test/less/extract-and-length.less +133 -0
- data/lib/less/js/test/less/functions.less +130 -6
- data/lib/less/js/test/less/globalVars/extended.json +5 -0
- data/lib/less/js/test/less/globalVars/extended.less +10 -0
- data/lib/less/js/test/less/globalVars/simple.json +3 -0
- data/lib/less/js/test/less/globalVars/simple.less +3 -0
- data/lib/less/js/test/less/ie-filters.less +7 -0
- data/lib/less/js/test/less/import/deeper/import-once-test-a.less +1 -0
- data/lib/less/js/test/less/import/import-and-relative-paths-test.less +17 -0
- data/lib/less/js/test/less/import/import-charset-test.less +1 -0
- data/lib/less/js/test/less/import/import-interpolation.less +1 -0
- data/lib/less/js/test/less/import/import-interpolation2.less +5 -0
- data/lib/less/js/test/less/import/import-once-test-c.less +6 -0
- data/lib/less/js/test/less/import/import-reference.less +51 -0
- data/lib/less/js/test/less/import/import-test-a.less +1 -0
- data/lib/less/js/test/less/import/import-test-c.less +0 -1
- data/lib/less/js/test/less/import/import-test-f.less +5 -0
- data/lib/less/js/test/less/import/imports/font.less +8 -0
- data/lib/less/js/test/less/import/imports/logo.less +5 -0
- data/lib/less/js/test/less/import/invalid-css.less +1 -0
- data/lib/less/js/test/less/import/urls.less +1 -0
- data/lib/less/js/test/less/import-inline.less +2 -0
- data/lib/less/js/test/less/import-interpolation.less +8 -0
- data/lib/less/js/test/less/import-once.less +6 -0
- data/lib/less/js/test/less/import-reference.less +21 -0
- data/lib/less/js/test/less/import.less +13 -3
- data/lib/less/js/test/less/javascript.less +5 -3
- data/lib/less/js/test/less/legacy/legacy.less +7 -0
- data/lib/less/js/test/less/media.less +158 -3
- data/lib/less/js/test/less/merge.less +78 -0
- data/lib/less/js/test/less/mixins-args.less +93 -15
- data/lib/less/js/test/less/mixins-guards-default-func.less +195 -0
- data/lib/less/js/test/less/mixins-guards.less +65 -0
- data/lib/less/js/test/less/mixins-important.less +8 -1
- data/lib/less/js/test/less/mixins-interpolated.less +69 -0
- data/lib/less/js/test/less/mixins-named-args.less +36 -0
- data/lib/less/js/test/less/mixins-nested.less +2 -2
- data/lib/less/js/test/less/mixins-pattern.less +4 -1
- data/lib/less/js/test/less/mixins.less +74 -0
- data/lib/less/js/test/less/modifyVars/extended.json +5 -0
- data/lib/less/js/test/less/modifyVars/extended.less +11 -0
- data/lib/less/js/test/less/no-js-errors/no-js-errors.less +3 -0
- data/lib/less/js/test/less/no-js-errors/no-js-errors.txt +4 -0
- data/lib/less/js/test/less/no-output.less +2 -0
- data/lib/less/js/test/less/operations.less +27 -27
- data/lib/less/js/test/less/parens.less +24 -5
- data/lib/less/js/test/less/property-name-interp.less +53 -0
- data/lib/less/js/test/less/scope.less +73 -1
- data/lib/less/js/test/less/selectors.less +101 -0
- data/lib/less/js/test/less/sourcemaps/basic.json +3 -0
- data/lib/less/js/test/less/sourcemaps/basic.less +27 -0
- data/lib/less/js/test/less/sourcemaps/imported.css +7 -0
- data/lib/less/js/test/less/static-urls/urls.less +33 -0
- data/lib/less/js/test/less/strings.less +7 -1
- data/lib/less/js/test/less/url-args/urls.less +63 -0
- data/lib/less/js/test/less/urls.less +72 -0
- data/lib/less/js/test/less/variables-in-at-rules.less +20 -0
- data/lib/less/js/test/less/variables.less +42 -13
- data/lib/less/js/test/less/whitespace.less +7 -0
- data/lib/less/js/test/less-test.js +251 -65
- data/lib/less/js/test/rhino/test-header.js +15 -0
- data/lib/less/js/test/sourcemaps/basic.json +1 -0
- data/lib/less/js/test/sourcemaps/index.html +17 -0
- data/lib/less/loader.rb +191 -27
- data/lib/less/parser.rb +47 -8
- data/lib/less/version.rb +2 -2
- data/spec/less/loader_spec.rb +45 -0
- data/spec/less/parser_spec.rb +43 -17
- data/spec/less/some/some.css +0 -0
- data/spec/less/some/some.less +4 -0
- metadata +352 -57
- data/lib/less/js/CHANGELOG +0 -41
- data/lib/less/js/Makefile +0 -75
- data/lib/less/js/build/ecma-5.js +0 -120
- data/lib/less/js/build/header.js +0 -7
- data/lib/less/js/lib/less/cssmin.js +0 -355
@@ -1,53 +1,158 @@
|
|
1
1
|
(function (tree) {
|
2
2
|
|
3
3
|
tree.mixin = {};
|
4
|
-
tree.mixin.Call = function (elements, args, index,
|
4
|
+
tree.mixin.Call = function (elements, args, index, currentFileInfo, important) {
|
5
5
|
this.selector = new(tree.Selector)(elements);
|
6
|
-
this.arguments = args;
|
6
|
+
this.arguments = (args && args.length) ? args : null;
|
7
7
|
this.index = index;
|
8
|
-
this.
|
8
|
+
this.currentFileInfo = currentFileInfo;
|
9
9
|
this.important = important;
|
10
10
|
};
|
11
11
|
tree.mixin.Call.prototype = {
|
12
|
+
type: "MixinCall",
|
13
|
+
accept: function (visitor) {
|
14
|
+
if (this.selector) {
|
15
|
+
this.selector = visitor.visit(this.selector);
|
16
|
+
}
|
17
|
+
if (this.arguments) {
|
18
|
+
this.arguments = visitor.visitArray(this.arguments);
|
19
|
+
}
|
20
|
+
},
|
12
21
|
eval: function (env) {
|
13
|
-
var mixins, args, rules = [], match = false
|
22
|
+
var mixins, mixin, args, rules = [], match = false, i, m, f, isRecursive, isOneFound, rule,
|
23
|
+
candidates = [], candidate, conditionResult = [], defaultFunc = tree.defaultFunc,
|
24
|
+
defaultResult, defNone = 0, defTrue = 1, defFalse = 2, count;
|
14
25
|
|
15
|
-
|
26
|
+
args = this.arguments && this.arguments.map(function (a) {
|
27
|
+
return { name: a.name, value: a.value.eval(env) };
|
28
|
+
});
|
29
|
+
|
30
|
+
for (i = 0; i < env.frames.length; i++) {
|
16
31
|
if ((mixins = env.frames[i].find(this.selector)).length > 0) {
|
17
|
-
|
18
|
-
|
19
|
-
|
32
|
+
isOneFound = true;
|
33
|
+
|
34
|
+
// To make `default()` function independent of definition order we have two "subpasses" here.
|
35
|
+
// At first we evaluate each guard *twice* (with `default() == true` and `default() == false`),
|
36
|
+
// and build candidate list with corresponding flags. Then, when we know all possible matches,
|
37
|
+
// we make a final decision.
|
38
|
+
|
39
|
+
for (m = 0; m < mixins.length; m++) {
|
40
|
+
mixin = mixins[m];
|
41
|
+
isRecursive = false;
|
42
|
+
for(f = 0; f < env.frames.length; f++) {
|
43
|
+
if ((!(mixin instanceof tree.mixin.Definition)) && mixin === (env.frames[f].originalRuleset || env.frames[f])) {
|
44
|
+
isRecursive = true;
|
45
|
+
break;
|
46
|
+
}
|
47
|
+
}
|
48
|
+
if (isRecursive) {
|
49
|
+
continue;
|
50
|
+
}
|
51
|
+
|
52
|
+
if (mixin.matchArgs(args, env)) {
|
53
|
+
candidate = {mixin: mixin, group: defNone};
|
54
|
+
|
55
|
+
if (mixin.matchCondition) {
|
56
|
+
for (f = 0; f < 2; f++) {
|
57
|
+
defaultFunc.value(f);
|
58
|
+
conditionResult[f] = mixin.matchCondition(args, env);
|
59
|
+
}
|
60
|
+
if (conditionResult[0] || conditionResult[1]) {
|
61
|
+
if (conditionResult[0] != conditionResult[1]) {
|
62
|
+
candidate.group = conditionResult[1] ?
|
63
|
+
defTrue : defFalse;
|
64
|
+
}
|
65
|
+
|
66
|
+
candidates.push(candidate);
|
67
|
+
}
|
68
|
+
}
|
69
|
+
else {
|
70
|
+
candidates.push(candidate);
|
71
|
+
}
|
72
|
+
|
73
|
+
match = true;
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
defaultFunc.reset();
|
78
|
+
|
79
|
+
count = [0, 0, 0];
|
80
|
+
for (m = 0; m < candidates.length; m++) {
|
81
|
+
count[candidates[m].group]++;
|
82
|
+
}
|
83
|
+
|
84
|
+
if (count[defNone] > 0) {
|
85
|
+
defaultResult = defFalse;
|
86
|
+
} else {
|
87
|
+
defaultResult = defTrue;
|
88
|
+
if ((count[defTrue] + count[defFalse]) > 1) {
|
89
|
+
throw { type: 'Runtime',
|
90
|
+
message: 'Ambiguous use of `default()` found when matching for `'
|
91
|
+
+ this.format(args) + '`',
|
92
|
+
index: this.index, filename: this.currentFileInfo.filename };
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
for (m = 0; m < candidates.length; m++) {
|
97
|
+
candidate = candidates[m].group;
|
98
|
+
if ((candidate === defNone) || (candidate === defaultResult)) {
|
20
99
|
try {
|
100
|
+
mixin = candidates[m].mixin;
|
101
|
+
if (!(mixin instanceof tree.mixin.Definition)) {
|
102
|
+
mixin = new tree.mixin.Definition("", [], mixin.rules, null, false);
|
103
|
+
mixin.originalRuleset = mixins[m].originalRuleset || mixins[m];
|
104
|
+
}
|
21
105
|
Array.prototype.push.apply(
|
22
|
-
rules,
|
23
|
-
match = true;
|
106
|
+
rules, mixin.evalCall(env, args, this.important).rules);
|
24
107
|
} catch (e) {
|
25
|
-
throw { message: e.message, index: this.index, filename: this.filename, stack: e.stack };
|
108
|
+
throw { message: e.message, index: this.index, filename: this.currentFileInfo.filename, stack: e.stack };
|
26
109
|
}
|
27
110
|
}
|
28
111
|
}
|
112
|
+
|
29
113
|
if (match) {
|
114
|
+
if (!this.currentFileInfo || !this.currentFileInfo.reference) {
|
115
|
+
for (i = 0; i < rules.length; i++) {
|
116
|
+
rule = rules[i];
|
117
|
+
if (rule.markReferenced) {
|
118
|
+
rule.markReferenced();
|
119
|
+
}
|
120
|
+
}
|
121
|
+
}
|
30
122
|
return rules;
|
31
|
-
} else {
|
32
|
-
throw { type: 'Runtime',
|
33
|
-
message: 'No matching definition was found for `' +
|
34
|
-
this.selector.toCSS().trim() + '(' +
|
35
|
-
this.arguments.map(function (a) {
|
36
|
-
return a.toCSS();
|
37
|
-
}).join(', ') + ")`",
|
38
|
-
index: this.index, filename: this.filename };
|
39
123
|
}
|
40
124
|
}
|
41
125
|
}
|
42
|
-
|
43
|
-
|
44
|
-
|
126
|
+
if (isOneFound) {
|
127
|
+
throw { type: 'Runtime',
|
128
|
+
message: 'No matching definition was found for `' + this.format(args) + '`',
|
129
|
+
index: this.index, filename: this.currentFileInfo.filename };
|
130
|
+
} else {
|
131
|
+
throw { type: 'Name',
|
132
|
+
message: this.selector.toCSS().trim() + " is undefined",
|
133
|
+
index: this.index, filename: this.currentFileInfo.filename };
|
134
|
+
}
|
135
|
+
},
|
136
|
+
format: function (args) {
|
137
|
+
return this.selector.toCSS().trim() + '(' +
|
138
|
+
(args ? args.map(function (a) {
|
139
|
+
var argValue = "";
|
140
|
+
if (a.name) {
|
141
|
+
argValue += a.name + ":";
|
142
|
+
}
|
143
|
+
if (a.value.toCSS) {
|
144
|
+
argValue += a.value.toCSS();
|
145
|
+
} else {
|
146
|
+
argValue += "???";
|
147
|
+
}
|
148
|
+
return argValue;
|
149
|
+
}).join(', ') : "") + ")";
|
45
150
|
}
|
46
151
|
};
|
47
152
|
|
48
|
-
tree.mixin.Definition = function (name, params, rules, condition, variadic) {
|
153
|
+
tree.mixin.Definition = function (name, params, rules, condition, variadic, frames) {
|
49
154
|
this.name = name;
|
50
|
-
this.selectors = [new(tree.Selector)([new(tree.Element)(null, name)])];
|
155
|
+
this.selectors = [new(tree.Selector)([new(tree.Element)(null, name, this.index, this.currentFileInfo)])];
|
51
156
|
this.params = params;
|
52
157
|
this.condition = condition;
|
53
158
|
this.variadic = variadic;
|
@@ -55,75 +160,150 @@ tree.mixin.Definition = function (name, params, rules, condition, variadic) {
|
|
55
160
|
this.rules = rules;
|
56
161
|
this._lookups = {};
|
57
162
|
this.required = params.reduce(function (count, p) {
|
58
|
-
if (!p.name || (p.name && !p.value)) { return count + 1 }
|
59
|
-
else { return count }
|
163
|
+
if (!p.name || (p.name && !p.value)) { return count + 1; }
|
164
|
+
else { return count; }
|
60
165
|
}, 0);
|
61
166
|
this.parent = tree.Ruleset.prototype;
|
62
|
-
this.frames =
|
167
|
+
this.frames = frames;
|
63
168
|
};
|
64
169
|
tree.mixin.Definition.prototype = {
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
170
|
+
type: "MixinDefinition",
|
171
|
+
accept: function (visitor) {
|
172
|
+
if (this.params && this.params.length) {
|
173
|
+
this.params = visitor.visitArray(this.params);
|
174
|
+
}
|
175
|
+
this.rules = visitor.visitArray(this.rules);
|
176
|
+
if (this.condition) {
|
177
|
+
this.condition = visitor.visit(this.condition);
|
178
|
+
}
|
179
|
+
},
|
180
|
+
variable: function (name) { return this.parent.variable.call(this, name); },
|
181
|
+
variables: function () { return this.parent.variables.call(this); },
|
182
|
+
find: function () { return this.parent.find.apply(this, arguments); },
|
183
|
+
rulesets: function () { return this.parent.rulesets.apply(this); },
|
184
|
+
|
185
|
+
evalParams: function (env, mixinEnv, args, evaldArguments) {
|
186
|
+
/*jshint boss:true */
|
187
|
+
var frame = new(tree.Ruleset)(null, null),
|
188
|
+
varargs, arg,
|
189
|
+
params = this.params.slice(0),
|
190
|
+
i, j, val, name, isNamedFound, argIndex, argsLength = 0;
|
191
|
+
|
192
|
+
mixinEnv = new tree.evalEnv(mixinEnv, [frame].concat(mixinEnv.frames));
|
193
|
+
|
194
|
+
if (args) {
|
195
|
+
args = args.slice(0);
|
196
|
+
argsLength = args.length;
|
197
|
+
|
198
|
+
for(i = 0; i < argsLength; i++) {
|
199
|
+
arg = args[i];
|
200
|
+
if (name = (arg && arg.name)) {
|
201
|
+
isNamedFound = false;
|
202
|
+
for(j = 0; j < params.length; j++) {
|
203
|
+
if (!evaldArguments[j] && name === params[j].name) {
|
204
|
+
evaldArguments[j] = arg.value.eval(env);
|
205
|
+
frame.prependRule(new(tree.Rule)(name, arg.value.eval(env)));
|
206
|
+
isNamedFound = true;
|
207
|
+
break;
|
208
|
+
}
|
209
|
+
}
|
210
|
+
if (isNamedFound) {
|
211
|
+
args.splice(i, 1);
|
212
|
+
i--;
|
213
|
+
continue;
|
214
|
+
} else {
|
215
|
+
throw { type: 'Runtime', message: "Named argument for " + this.name +
|
216
|
+
' ' + args[i].name + ' not found' };
|
217
|
+
}
|
218
|
+
}
|
219
|
+
}
|
220
|
+
}
|
221
|
+
argIndex = 0;
|
222
|
+
for (i = 0; i < params.length; i++) {
|
223
|
+
if (evaldArguments[i]) { continue; }
|
224
|
+
|
225
|
+
arg = args && args[argIndex];
|
226
|
+
|
227
|
+
if (name = params[i].name) {
|
228
|
+
if (params[i].variadic) {
|
77
229
|
varargs = [];
|
78
|
-
for (
|
79
|
-
varargs.push(args[j].eval(env));
|
230
|
+
for (j = argIndex; j < argsLength; j++) {
|
231
|
+
varargs.push(args[j].value.eval(env));
|
80
232
|
}
|
81
|
-
frame.
|
82
|
-
} else if (val = (args && args[i]) || this.params[i].value) {
|
83
|
-
frame.rules.unshift(new(tree.Rule)(name, val.eval(env)));
|
233
|
+
frame.prependRule(new(tree.Rule)(name, new(tree.Expression)(varargs).eval(env)));
|
84
234
|
} else {
|
85
|
-
|
86
|
-
|
235
|
+
val = arg && arg.value;
|
236
|
+
if (val) {
|
237
|
+
val = val.eval(env);
|
238
|
+
} else if (params[i].value) {
|
239
|
+
val = params[i].value.eval(mixinEnv);
|
240
|
+
frame.resetCache();
|
241
|
+
} else {
|
242
|
+
throw { type: 'Runtime', message: "wrong number of arguments for " + this.name +
|
243
|
+
' (' + argsLength + ' for ' + this.arity + ')' };
|
244
|
+
}
|
245
|
+
|
246
|
+
frame.prependRule(new(tree.Rule)(name, val));
|
247
|
+
evaldArguments[i] = val;
|
248
|
+
}
|
249
|
+
}
|
250
|
+
|
251
|
+
if (params[i].variadic && args) {
|
252
|
+
for (j = argIndex; j < argsLength; j++) {
|
253
|
+
evaldArguments[j] = args[j].value.eval(env);
|
87
254
|
}
|
88
255
|
}
|
256
|
+
argIndex++;
|
89
257
|
}
|
258
|
+
|
90
259
|
return frame;
|
91
260
|
},
|
92
|
-
eval: function (env
|
93
|
-
|
261
|
+
eval: function (env) {
|
262
|
+
return new tree.mixin.Definition(this.name, this.params, this.rules, this.condition, this.variadic, this.frames || env.frames.slice(0));
|
263
|
+
},
|
264
|
+
evalCall: function (env, args, important) {
|
265
|
+
var _arguments = [],
|
266
|
+
mixinFrames = this.frames ? this.frames.concat(env.frames) : env.frames,
|
267
|
+
frame = this.evalParams(env, new(tree.evalEnv)(env, mixinFrames), args, _arguments),
|
268
|
+
rules, ruleset;
|
94
269
|
|
95
|
-
|
96
|
-
_arguments.push(args[i] || this.params[i].value);
|
97
|
-
}
|
98
|
-
frame.rules.unshift(new(tree.Rule)('@arguments', new(tree.Expression)(_arguments).eval(env)));
|
270
|
+
frame.prependRule(new(tree.Rule)('@arguments', new(tree.Expression)(_arguments).eval(env)));
|
99
271
|
|
100
|
-
rules =
|
101
|
-
this.rules.map(function (r) {
|
102
|
-
return new(tree.Rule)(r.name, r.value, '!important', r.index);
|
103
|
-
}) : this.rules.slice(0);
|
272
|
+
rules = this.rules.slice(0);
|
104
273
|
|
105
|
-
|
106
|
-
|
107
|
-
|
274
|
+
ruleset = new(tree.Ruleset)(null, rules);
|
275
|
+
ruleset.originalRuleset = this;
|
276
|
+
ruleset = ruleset.eval(new(tree.evalEnv)(env, [this, frame].concat(mixinFrames)));
|
277
|
+
if (important) {
|
278
|
+
ruleset = this.parent.makeImportant.apply(ruleset);
|
279
|
+
}
|
280
|
+
return ruleset;
|
108
281
|
},
|
109
|
-
|
110
|
-
|
282
|
+
matchCondition: function (args, env) {
|
283
|
+
if (this.condition && !this.condition.eval(
|
284
|
+
new(tree.evalEnv)(env,
|
285
|
+
[this.evalParams(env, new(tree.evalEnv)(env, this.frames.concat(env.frames)), args, [])] // the parameter variables
|
286
|
+
.concat(this.frames) // the parent namespace/mixin frames
|
287
|
+
.concat(env.frames)))) { // the current environment frames
|
288
|
+
return false;
|
289
|
+
}
|
290
|
+
return true;
|
291
|
+
},
|
292
|
+
matchArgs: function (args, env) {
|
293
|
+
var argsLength = (args && args.length) || 0, len;
|
111
294
|
|
112
295
|
if (! this.variadic) {
|
113
|
-
if (argsLength < this.required) { return false }
|
114
|
-
if (argsLength > this.params.length) { return false }
|
115
|
-
|
296
|
+
if (argsLength < this.required) { return false; }
|
297
|
+
if (argsLength > this.params.length) { return false; }
|
298
|
+
} else {
|
299
|
+
if (argsLength < (this.required - 1)) { return false; }
|
116
300
|
}
|
117
301
|
|
118
|
-
if (this.condition && !this.condition.eval({
|
119
|
-
frames: [this.evalParams(env, args)].concat(env.frames)
|
120
|
-
})) { return false }
|
121
|
-
|
122
302
|
len = Math.min(argsLength, this.arity);
|
123
303
|
|
124
304
|
for (var i = 0; i < len; i++) {
|
125
|
-
if (!this.params[i].name) {
|
126
|
-
if (args[i].eval(env).toCSS() != this.params[i].value.eval(env).toCSS()) {
|
305
|
+
if (!this.params[i].name && !this.params[i].variadic) {
|
306
|
+
if (args[i].value.eval(env).toCSS() != this.params[i].value.eval(env).toCSS()) {
|
127
307
|
return false;
|
128
308
|
}
|
129
309
|
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
(function (tree) {
|
2
|
+
|
3
|
+
tree.Negative = function (node) {
|
4
|
+
this.value = node;
|
5
|
+
};
|
6
|
+
tree.Negative.prototype = {
|
7
|
+
type: "Negative",
|
8
|
+
accept: function (visitor) {
|
9
|
+
this.value = visitor.visit(this.value);
|
10
|
+
},
|
11
|
+
genCSS: function (env, output) {
|
12
|
+
output.add('-');
|
13
|
+
this.value.genCSS(env, output);
|
14
|
+
},
|
15
|
+
toCSS: tree.toCSS,
|
16
|
+
eval: function (env) {
|
17
|
+
if (env.isMathOn()) {
|
18
|
+
return (new(tree.Operation)('*', [new(tree.Dimension)(-1), this.value])).eval(env);
|
19
|
+
}
|
20
|
+
return new(tree.Negative)(this.value.eval(env));
|
21
|
+
}
|
22
|
+
};
|
23
|
+
|
24
|
+
})(require('../tree'));
|
@@ -1,26 +1,51 @@
|
|
1
1
|
(function (tree) {
|
2
2
|
|
3
|
-
tree.Operation = function (op, operands) {
|
3
|
+
tree.Operation = function (op, operands, isSpaced) {
|
4
4
|
this.op = op.trim();
|
5
5
|
this.operands = operands;
|
6
|
+
this.isSpaced = isSpaced;
|
6
7
|
};
|
7
|
-
tree.Operation.prototype
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
tree.Operation.prototype = {
|
9
|
+
type: "Operation",
|
10
|
+
accept: function (visitor) {
|
11
|
+
this.operands = visitor.visit(this.operands);
|
12
|
+
},
|
13
|
+
eval: function (env) {
|
14
|
+
var a = this.operands[0].eval(env),
|
15
|
+
b = this.operands[1].eval(env);
|
11
16
|
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
if (env.isMathOn()) {
|
18
|
+
if (a instanceof tree.Dimension && b instanceof tree.Color) {
|
19
|
+
a = a.toColor();
|
20
|
+
}
|
21
|
+
if (b instanceof tree.Dimension && a instanceof tree.Color) {
|
22
|
+
b = b.toColor();
|
23
|
+
}
|
24
|
+
if (!a.operate) {
|
25
|
+
throw { type: "Operation",
|
26
|
+
message: "Operation on an invalid type" };
|
27
|
+
}
|
28
|
+
|
29
|
+
return a.operate(env, this.op, b);
|
15
30
|
} else {
|
16
|
-
|
17
|
-
message: "Can't substract or divide a color from a number" };
|
31
|
+
return new(tree.Operation)(this.op, [a, b], this.isSpaced);
|
18
32
|
}
|
19
|
-
}
|
20
|
-
|
33
|
+
},
|
34
|
+
genCSS: function (env, output) {
|
35
|
+
this.operands[0].genCSS(env, output);
|
36
|
+
if (this.isSpaced) {
|
37
|
+
output.add(" ");
|
38
|
+
}
|
39
|
+
output.add(this.op);
|
40
|
+
if (this.isSpaced) {
|
41
|
+
output.add(" ");
|
42
|
+
}
|
43
|
+
this.operands[1].genCSS(env, output);
|
44
|
+
},
|
45
|
+
toCSS: tree.toCSS
|
21
46
|
};
|
22
47
|
|
23
|
-
tree.operate = function (op, a, b) {
|
48
|
+
tree.operate = function (env, op, a, b) {
|
24
49
|
switch (op) {
|
25
50
|
case '+': return a + b;
|
26
51
|
case '-': return a - b;
|
@@ -5,9 +5,16 @@ tree.Paren = function (node) {
|
|
5
5
|
this.value = node;
|
6
6
|
};
|
7
7
|
tree.Paren.prototype = {
|
8
|
-
|
9
|
-
|
8
|
+
type: "Paren",
|
9
|
+
accept: function (visitor) {
|
10
|
+
this.value = visitor.visit(this.value);
|
10
11
|
},
|
12
|
+
genCSS: function (env, output) {
|
13
|
+
output.add('(');
|
14
|
+
this.value.genCSS(env, output);
|
15
|
+
output.add(')');
|
16
|
+
},
|
17
|
+
toCSS: tree.toCSS,
|
11
18
|
eval: function (env) {
|
12
19
|
return new(tree.Paren)(this.value.eval(env));
|
13
20
|
}
|
@@ -1,28 +1,47 @@
|
|
1
1
|
(function (tree) {
|
2
2
|
|
3
|
-
tree.Quoted = function (str, content, escaped,
|
3
|
+
tree.Quoted = function (str, content, escaped, index, currentFileInfo) {
|
4
4
|
this.escaped = escaped;
|
5
5
|
this.value = content || '';
|
6
6
|
this.quote = str.charAt(0);
|
7
|
-
this.index =
|
7
|
+
this.index = index;
|
8
|
+
this.currentFileInfo = currentFileInfo;
|
8
9
|
};
|
9
10
|
tree.Quoted.prototype = {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
type: "Quoted",
|
12
|
+
genCSS: function (env, output) {
|
13
|
+
if (!this.escaped) {
|
14
|
+
output.add(this.quote, this.currentFileInfo, this.index);
|
15
|
+
}
|
16
|
+
output.add(this.value);
|
17
|
+
if (!this.escaped) {
|
18
|
+
output.add(this.quote);
|
15
19
|
}
|
16
20
|
},
|
21
|
+
toCSS: tree.toCSS,
|
17
22
|
eval: function (env) {
|
18
23
|
var that = this;
|
19
24
|
var value = this.value.replace(/`([^`]+)`/g, function (_, exp) {
|
20
25
|
return new(tree.JavaScript)(exp, that.index, true).eval(env).value;
|
21
26
|
}).replace(/@\{([\w-]+)\}/g, function (_, name) {
|
22
|
-
var v = new(tree.Variable)('@' + name, that.index).eval(env);
|
23
|
-
return (
|
27
|
+
var v = new(tree.Variable)('@' + name, that.index, that.currentFileInfo).eval(env, true);
|
28
|
+
return (v instanceof tree.Quoted) ? v.value : v.toCSS();
|
24
29
|
});
|
25
|
-
return new(tree.Quoted)(this.quote + value + this.quote, value, this.escaped, this.index);
|
30
|
+
return new(tree.Quoted)(this.quote + value + this.quote, value, this.escaped, this.index, this.currentFileInfo);
|
31
|
+
},
|
32
|
+
compare: function (x) {
|
33
|
+
if (!x.toCSS) {
|
34
|
+
return -1;
|
35
|
+
}
|
36
|
+
|
37
|
+
var left = this.toCSS(),
|
38
|
+
right = x.toCSS();
|
39
|
+
|
40
|
+
if (left === right) {
|
41
|
+
return 0;
|
42
|
+
}
|
43
|
+
|
44
|
+
return left < right ? -1 : 1;
|
26
45
|
}
|
27
46
|
};
|
28
47
|
|
@@ -1,42 +1,90 @@
|
|
1
1
|
(function (tree) {
|
2
2
|
|
3
|
-
tree.Rule = function (name, value, important, index, inline) {
|
3
|
+
tree.Rule = function (name, value, important, merge, index, currentFileInfo, inline) {
|
4
4
|
this.name = name;
|
5
|
-
this.value = (value instanceof tree.Value) ? value : new(tree.Value)([value]);
|
5
|
+
this.value = (value instanceof tree.Value || value instanceof tree.Ruleset) ? value : new(tree.Value)([value]);
|
6
6
|
this.important = important ? ' ' + important.trim() : '';
|
7
|
+
this.merge = merge;
|
7
8
|
this.index = index;
|
9
|
+
this.currentFileInfo = currentFileInfo;
|
8
10
|
this.inline = inline || false;
|
9
|
-
|
10
|
-
if (name.charAt(0) === '@') {
|
11
|
-
this.variable = true;
|
12
|
-
} else { this.variable = false }
|
13
|
-
};
|
14
|
-
tree.Rule.prototype.toCSS = function (env) {
|
15
|
-
if (this.variable) { return "" }
|
16
|
-
else {
|
17
|
-
return this.name + (env.compress ? ':' : ': ') +
|
18
|
-
this.value.toCSS(env) +
|
19
|
-
this.important + (this.inline ? "" : ";");
|
20
|
-
}
|
11
|
+
this.variable = name.charAt && (name.charAt(0) === '@');
|
21
12
|
};
|
22
13
|
|
23
|
-
tree.Rule.prototype
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
14
|
+
tree.Rule.prototype = {
|
15
|
+
type: "Rule",
|
16
|
+
accept: function (visitor) {
|
17
|
+
this.value = visitor.visit(this.value);
|
18
|
+
},
|
19
|
+
genCSS: function (env, output) {
|
20
|
+
output.add(this.name + (env.compress ? ':' : ': '), this.currentFileInfo, this.index);
|
21
|
+
try {
|
22
|
+
this.value.genCSS(env, output);
|
23
|
+
}
|
24
|
+
catch(e) {
|
25
|
+
e.index = this.index;
|
26
|
+
e.filename = this.currentFileInfo.filename;
|
27
|
+
throw e;
|
28
|
+
}
|
29
|
+
output.add(this.important + ((this.inline || (env.lastRule && env.compress)) ? "" : ";"), this.currentFileInfo, this.index);
|
30
|
+
},
|
31
|
+
toCSS: tree.toCSS,
|
32
|
+
eval: function (env) {
|
33
|
+
var strictMathBypass = false, name = this.name, evaldValue;
|
34
|
+
if (typeof name !== "string") {
|
35
|
+
// expand 'primitive' name directly to get
|
36
|
+
// things faster (~10% for benchmark.less):
|
37
|
+
name = (name.length === 1)
|
38
|
+
&& (name[0] instanceof tree.Keyword)
|
39
|
+
? name[0].value : evalName(env, name);
|
40
|
+
}
|
41
|
+
if (name === "font" && !env.strictMath) {
|
42
|
+
strictMathBypass = true;
|
43
|
+
env.strictMath = true;
|
44
|
+
}
|
45
|
+
try {
|
46
|
+
evaldValue = this.value.eval(env);
|
47
|
+
|
48
|
+
if (!this.variable && evaldValue.type === "DetachedRuleset") {
|
49
|
+
throw { message: "Rulesets cannot be evaluated on a property.",
|
50
|
+
index: this.index, filename: this.currentFileInfo.filename };
|
51
|
+
}
|
34
52
|
|
35
|
-
tree.
|
36
|
-
|
37
|
-
|
53
|
+
return new(tree.Rule)(name,
|
54
|
+
evaldValue,
|
55
|
+
this.important,
|
56
|
+
this.merge,
|
57
|
+
this.index, this.currentFileInfo, this.inline);
|
58
|
+
}
|
59
|
+
catch(e) {
|
60
|
+
if (typeof e.index !== 'number') {
|
61
|
+
e.index = this.index;
|
62
|
+
e.filename = this.currentFileInfo.filename;
|
63
|
+
}
|
64
|
+
throw e;
|
65
|
+
}
|
66
|
+
finally {
|
67
|
+
if (strictMathBypass) {
|
68
|
+
env.strictMath = false;
|
69
|
+
}
|
70
|
+
}
|
38
71
|
},
|
39
|
-
|
72
|
+
makeImportant: function () {
|
73
|
+
return new(tree.Rule)(this.name,
|
74
|
+
this.value,
|
75
|
+
"!important",
|
76
|
+
this.merge,
|
77
|
+
this.index, this.currentFileInfo, this.inline);
|
78
|
+
}
|
40
79
|
};
|
41
80
|
|
81
|
+
function evalName(env, name) {
|
82
|
+
var value = "", i, n = name.length,
|
83
|
+
output = {add: function (s) {value += s;}};
|
84
|
+
for (i = 0; i < n; i++) {
|
85
|
+
name[i].eval(env).genCSS(env, output);
|
86
|
+
}
|
87
|
+
return value;
|
88
|
+
}
|
89
|
+
|
42
90
|
})(require('../tree'));
|