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
@@ -7,36 +7,43 @@ tree.Condition = function (op, l, r, i, negate) {
|
|
7
7
|
this.index = i;
|
8
8
|
this.negate = negate;
|
9
9
|
};
|
10
|
-
tree.Condition.prototype
|
11
|
-
|
12
|
-
|
10
|
+
tree.Condition.prototype = {
|
11
|
+
type: "Condition",
|
12
|
+
accept: function (visitor) {
|
13
|
+
this.lvalue = visitor.visit(this.lvalue);
|
14
|
+
this.rvalue = visitor.visit(this.rvalue);
|
15
|
+
},
|
16
|
+
eval: function (env) {
|
17
|
+
var a = this.lvalue.eval(env),
|
18
|
+
b = this.rvalue.eval(env);
|
13
19
|
|
14
|
-
|
20
|
+
var i = this.index, result;
|
15
21
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
22
|
+
result = (function (op) {
|
23
|
+
switch (op) {
|
24
|
+
case 'and':
|
25
|
+
return a && b;
|
26
|
+
case 'or':
|
27
|
+
return a || b;
|
28
|
+
default:
|
29
|
+
if (a.compare) {
|
30
|
+
result = a.compare(b);
|
31
|
+
} else if (b.compare) {
|
32
|
+
result = b.compare(a);
|
33
|
+
} else {
|
34
|
+
throw { type: "Type",
|
35
|
+
message: "Unable to perform comparison",
|
36
|
+
index: i };
|
37
|
+
}
|
38
|
+
switch (result) {
|
39
|
+
case -1: return op === '<' || op === '=<' || op === '<=';
|
40
|
+
case 0: return op === '=' || op === '>=' || op === '=<' || op === '<=';
|
41
|
+
case 1: return op === '>' || op === '>=';
|
42
|
+
}
|
43
|
+
}
|
44
|
+
})(this.op);
|
45
|
+
return this.negate ? !result : result;
|
46
|
+
}
|
40
47
|
};
|
41
48
|
|
42
49
|
})(require('../tree'));
|
@@ -0,0 +1,20 @@
|
|
1
|
+
(function (tree) {
|
2
|
+
|
3
|
+
tree.DetachedRuleset = function (ruleset, frames) {
|
4
|
+
this.ruleset = ruleset;
|
5
|
+
this.frames = frames;
|
6
|
+
};
|
7
|
+
tree.DetachedRuleset.prototype = {
|
8
|
+
type: "DetachedRuleset",
|
9
|
+
accept: function (visitor) {
|
10
|
+
this.ruleset = visitor.visit(this.ruleset);
|
11
|
+
},
|
12
|
+
eval: function (env) {
|
13
|
+
var frames = this.frames || env.frames.slice(0);
|
14
|
+
return new tree.DetachedRuleset(this.ruleset, frames);
|
15
|
+
},
|
16
|
+
callEval: function (env) {
|
17
|
+
return this.ruleset.eval(this.frames ? new(tree.evalEnv)(env, this.frames.concat(env.frames)) : env);
|
18
|
+
}
|
19
|
+
};
|
20
|
+
})(require('../tree'));
|
@@ -5,37 +5,109 @@
|
|
5
5
|
//
|
6
6
|
tree.Dimension = function (value, unit) {
|
7
7
|
this.value = parseFloat(value);
|
8
|
-
this.unit = unit
|
8
|
+
this.unit = (unit && unit instanceof tree.Unit) ? unit :
|
9
|
+
new(tree.Unit)(unit ? [unit] : undefined);
|
9
10
|
};
|
10
11
|
|
11
12
|
tree.Dimension.prototype = {
|
12
|
-
|
13
|
+
type: "Dimension",
|
14
|
+
accept: function (visitor) {
|
15
|
+
this.unit = visitor.visit(this.unit);
|
16
|
+
},
|
17
|
+
eval: function (env) {
|
18
|
+
return this;
|
19
|
+
},
|
13
20
|
toColor: function () {
|
14
21
|
return new(tree.Color)([this.value, this.value, this.value]);
|
15
22
|
},
|
16
|
-
|
17
|
-
|
18
|
-
|
23
|
+
genCSS: function (env, output) {
|
24
|
+
if ((env && env.strictUnits) && !this.unit.isSingular()) {
|
25
|
+
throw new Error("Multiple units in dimension. Correct the units or use the unit function. Bad unit: "+this.unit.toString());
|
26
|
+
}
|
27
|
+
|
28
|
+
var value = tree.fround(env, this.value),
|
29
|
+
strValue = String(value);
|
30
|
+
|
31
|
+
if (value !== 0 && value < 0.000001 && value > -0.000001) {
|
32
|
+
// would be output 1e-6 etc.
|
33
|
+
strValue = value.toFixed(20).replace(/0+$/, "");
|
34
|
+
}
|
35
|
+
|
36
|
+
if (env && env.compress) {
|
37
|
+
// Zero values doesn't need a unit
|
38
|
+
if (value === 0 && this.unit.isLength()) {
|
39
|
+
output.add(strValue);
|
40
|
+
return;
|
41
|
+
}
|
42
|
+
|
43
|
+
// Float values doesn't need a leading zero
|
44
|
+
if (value > 0 && value < 1) {
|
45
|
+
strValue = (strValue).substr(1);
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
output.add(strValue);
|
50
|
+
this.unit.genCSS(env, output);
|
19
51
|
},
|
52
|
+
toCSS: tree.toCSS,
|
20
53
|
|
21
54
|
// In an operation between two Dimensions,
|
22
55
|
// we default to the first Dimension's unit,
|
23
|
-
// so `1px +
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
56
|
+
// so `1px + 2` will yield `3px`.
|
57
|
+
operate: function (env, op, other) {
|
58
|
+
/*jshint noempty:false */
|
59
|
+
var value = tree.operate(env, op, this.value, other.value),
|
60
|
+
unit = this.unit.clone();
|
61
|
+
|
62
|
+
if (op === '+' || op === '-') {
|
63
|
+
if (unit.numerator.length === 0 && unit.denominator.length === 0) {
|
64
|
+
unit.numerator = other.unit.numerator.slice(0);
|
65
|
+
unit.denominator = other.unit.denominator.slice(0);
|
66
|
+
} else if (other.unit.numerator.length === 0 && unit.denominator.length === 0) {
|
67
|
+
// do nothing
|
68
|
+
} else {
|
69
|
+
other = other.convertTo(this.unit.usedUnits());
|
70
|
+
|
71
|
+
if(env.strictUnits && other.unit.toString() !== unit.toString()) {
|
72
|
+
throw new Error("Incompatible units. Change the units or use the unit function. Bad units: '" + unit.toString() +
|
73
|
+
"' and '" + other.unit.toString() + "'.");
|
74
|
+
}
|
75
|
+
|
76
|
+
value = tree.operate(env, op, this.value, other.value);
|
77
|
+
}
|
78
|
+
} else if (op === '*') {
|
79
|
+
unit.numerator = unit.numerator.concat(other.unit.numerator).sort();
|
80
|
+
unit.denominator = unit.denominator.concat(other.unit.denominator).sort();
|
81
|
+
unit.cancel();
|
82
|
+
} else if (op === '/') {
|
83
|
+
unit.numerator = unit.numerator.concat(other.unit.denominator).sort();
|
84
|
+
unit.denominator = unit.denominator.concat(other.unit.numerator).sort();
|
85
|
+
unit.cancel();
|
86
|
+
}
|
87
|
+
return new(tree.Dimension)(value, unit);
|
31
88
|
},
|
32
89
|
|
33
|
-
// TODO: Perform unit conversion before comparing
|
34
90
|
compare: function (other) {
|
35
91
|
if (other instanceof tree.Dimension) {
|
36
|
-
|
92
|
+
var a, b,
|
93
|
+
aValue, bValue;
|
94
|
+
|
95
|
+
if (this.unit.isEmpty() || other.unit.isEmpty()) {
|
96
|
+
a = this;
|
97
|
+
b = other;
|
98
|
+
} else {
|
99
|
+
a = this.unify();
|
100
|
+
b = other.unify();
|
101
|
+
if (a.unit.compare(b.unit) !== 0) {
|
102
|
+
return -1;
|
103
|
+
}
|
104
|
+
}
|
105
|
+
aValue = a.value;
|
106
|
+
bValue = b.value;
|
107
|
+
|
108
|
+
if (bValue > aValue) {
|
37
109
|
return -1;
|
38
|
-
} else if (
|
110
|
+
} else if (bValue < aValue) {
|
39
111
|
return 1;
|
40
112
|
} else {
|
41
113
|
return 0;
|
@@ -43,6 +115,209 @@ tree.Dimension.prototype = {
|
|
43
115
|
} else {
|
44
116
|
return -1;
|
45
117
|
}
|
118
|
+
},
|
119
|
+
|
120
|
+
unify: function () {
|
121
|
+
return this.convertTo({ length: 'px', duration: 's', angle: 'rad' });
|
122
|
+
},
|
123
|
+
|
124
|
+
convertTo: function (conversions) {
|
125
|
+
var value = this.value, unit = this.unit.clone(),
|
126
|
+
i, groupName, group, targetUnit, derivedConversions = {}, applyUnit;
|
127
|
+
|
128
|
+
if (typeof conversions === 'string') {
|
129
|
+
for(i in tree.UnitConversions) {
|
130
|
+
if (tree.UnitConversions[i].hasOwnProperty(conversions)) {
|
131
|
+
derivedConversions = {};
|
132
|
+
derivedConversions[i] = conversions;
|
133
|
+
}
|
134
|
+
}
|
135
|
+
conversions = derivedConversions;
|
136
|
+
}
|
137
|
+
applyUnit = function (atomicUnit, denominator) {
|
138
|
+
/*jshint loopfunc:true */
|
139
|
+
if (group.hasOwnProperty(atomicUnit)) {
|
140
|
+
if (denominator) {
|
141
|
+
value = value / (group[atomicUnit] / group[targetUnit]);
|
142
|
+
} else {
|
143
|
+
value = value * (group[atomicUnit] / group[targetUnit]);
|
144
|
+
}
|
145
|
+
|
146
|
+
return targetUnit;
|
147
|
+
}
|
148
|
+
|
149
|
+
return atomicUnit;
|
150
|
+
};
|
151
|
+
|
152
|
+
for (groupName in conversions) {
|
153
|
+
if (conversions.hasOwnProperty(groupName)) {
|
154
|
+
targetUnit = conversions[groupName];
|
155
|
+
group = tree.UnitConversions[groupName];
|
156
|
+
|
157
|
+
unit.map(applyUnit);
|
158
|
+
}
|
159
|
+
}
|
160
|
+
|
161
|
+
unit.cancel();
|
162
|
+
|
163
|
+
return new(tree.Dimension)(value, unit);
|
164
|
+
}
|
165
|
+
};
|
166
|
+
|
167
|
+
// http://www.w3.org/TR/css3-values/#absolute-lengths
|
168
|
+
tree.UnitConversions = {
|
169
|
+
length: {
|
170
|
+
'm': 1,
|
171
|
+
'cm': 0.01,
|
172
|
+
'mm': 0.001,
|
173
|
+
'in': 0.0254,
|
174
|
+
'px': 0.0254 / 96,
|
175
|
+
'pt': 0.0254 / 72,
|
176
|
+
'pc': 0.0254 / 72 * 12
|
177
|
+
},
|
178
|
+
duration: {
|
179
|
+
's': 1,
|
180
|
+
'ms': 0.001
|
181
|
+
},
|
182
|
+
angle: {
|
183
|
+
'rad': 1/(2*Math.PI),
|
184
|
+
'deg': 1/360,
|
185
|
+
'grad': 1/400,
|
186
|
+
'turn': 1
|
187
|
+
}
|
188
|
+
};
|
189
|
+
|
190
|
+
tree.Unit = function (numerator, denominator, backupUnit) {
|
191
|
+
this.numerator = numerator ? numerator.slice(0).sort() : [];
|
192
|
+
this.denominator = denominator ? denominator.slice(0).sort() : [];
|
193
|
+
this.backupUnit = backupUnit;
|
194
|
+
};
|
195
|
+
|
196
|
+
tree.Unit.prototype = {
|
197
|
+
type: "Unit",
|
198
|
+
clone: function () {
|
199
|
+
return new tree.Unit(this.numerator.slice(0), this.denominator.slice(0), this.backupUnit);
|
200
|
+
},
|
201
|
+
genCSS: function (env, output) {
|
202
|
+
if (this.numerator.length >= 1) {
|
203
|
+
output.add(this.numerator[0]);
|
204
|
+
} else
|
205
|
+
if (this.denominator.length >= 1) {
|
206
|
+
output.add(this.denominator[0]);
|
207
|
+
} else
|
208
|
+
if ((!env || !env.strictUnits) && this.backupUnit) {
|
209
|
+
output.add(this.backupUnit);
|
210
|
+
}
|
211
|
+
},
|
212
|
+
toCSS: tree.toCSS,
|
213
|
+
|
214
|
+
toString: function () {
|
215
|
+
var i, returnStr = this.numerator.join("*");
|
216
|
+
for (i = 0; i < this.denominator.length; i++) {
|
217
|
+
returnStr += "/" + this.denominator[i];
|
218
|
+
}
|
219
|
+
return returnStr;
|
220
|
+
},
|
221
|
+
|
222
|
+
compare: function (other) {
|
223
|
+
return this.is(other.toString()) ? 0 : -1;
|
224
|
+
},
|
225
|
+
|
226
|
+
is: function (unitString) {
|
227
|
+
return this.toString() === unitString;
|
228
|
+
},
|
229
|
+
|
230
|
+
isLength: function () {
|
231
|
+
return Boolean(this.toCSS().match(/px|em|%|in|cm|mm|pc|pt|ex/));
|
232
|
+
},
|
233
|
+
|
234
|
+
isEmpty: function () {
|
235
|
+
return this.numerator.length === 0 && this.denominator.length === 0;
|
236
|
+
},
|
237
|
+
|
238
|
+
isSingular: function() {
|
239
|
+
return this.numerator.length <= 1 && this.denominator.length === 0;
|
240
|
+
},
|
241
|
+
|
242
|
+
map: function(callback) {
|
243
|
+
var i;
|
244
|
+
|
245
|
+
for (i = 0; i < this.numerator.length; i++) {
|
246
|
+
this.numerator[i] = callback(this.numerator[i], false);
|
247
|
+
}
|
248
|
+
|
249
|
+
for (i = 0; i < this.denominator.length; i++) {
|
250
|
+
this.denominator[i] = callback(this.denominator[i], true);
|
251
|
+
}
|
252
|
+
},
|
253
|
+
|
254
|
+
usedUnits: function() {
|
255
|
+
var group, result = {}, mapUnit;
|
256
|
+
|
257
|
+
mapUnit = function (atomicUnit) {
|
258
|
+
/*jshint loopfunc:true */
|
259
|
+
if (group.hasOwnProperty(atomicUnit) && !result[groupName]) {
|
260
|
+
result[groupName] = atomicUnit;
|
261
|
+
}
|
262
|
+
|
263
|
+
return atomicUnit;
|
264
|
+
};
|
265
|
+
|
266
|
+
for (var groupName in tree.UnitConversions) {
|
267
|
+
if (tree.UnitConversions.hasOwnProperty(groupName)) {
|
268
|
+
group = tree.UnitConversions[groupName];
|
269
|
+
|
270
|
+
this.map(mapUnit);
|
271
|
+
}
|
272
|
+
}
|
273
|
+
|
274
|
+
return result;
|
275
|
+
},
|
276
|
+
|
277
|
+
cancel: function () {
|
278
|
+
var counter = {}, atomicUnit, i, backup;
|
279
|
+
|
280
|
+
for (i = 0; i < this.numerator.length; i++) {
|
281
|
+
atomicUnit = this.numerator[i];
|
282
|
+
if (!backup) {
|
283
|
+
backup = atomicUnit;
|
284
|
+
}
|
285
|
+
counter[atomicUnit] = (counter[atomicUnit] || 0) + 1;
|
286
|
+
}
|
287
|
+
|
288
|
+
for (i = 0; i < this.denominator.length; i++) {
|
289
|
+
atomicUnit = this.denominator[i];
|
290
|
+
if (!backup) {
|
291
|
+
backup = atomicUnit;
|
292
|
+
}
|
293
|
+
counter[atomicUnit] = (counter[atomicUnit] || 0) - 1;
|
294
|
+
}
|
295
|
+
|
296
|
+
this.numerator = [];
|
297
|
+
this.denominator = [];
|
298
|
+
|
299
|
+
for (atomicUnit in counter) {
|
300
|
+
if (counter.hasOwnProperty(atomicUnit)) {
|
301
|
+
var count = counter[atomicUnit];
|
302
|
+
|
303
|
+
if (count > 0) {
|
304
|
+
for (i = 0; i < count; i++) {
|
305
|
+
this.numerator.push(atomicUnit);
|
306
|
+
}
|
307
|
+
} else if (count < 0) {
|
308
|
+
for (i = 0; i < -count; i++) {
|
309
|
+
this.denominator.push(atomicUnit);
|
310
|
+
}
|
311
|
+
}
|
312
|
+
}
|
313
|
+
}
|
314
|
+
|
315
|
+
if (this.numerator.length === 0 && this.denominator.length === 0 && backup) {
|
316
|
+
this.backupUnit = backup;
|
317
|
+
}
|
318
|
+
|
319
|
+
this.numerator.sort();
|
320
|
+
this.denominator.sort();
|
46
321
|
}
|
47
322
|
};
|
48
323
|
|
@@ -1,35 +1,69 @@
|
|
1
1
|
(function (tree) {
|
2
2
|
|
3
|
-
tree.Directive = function (name, value,
|
4
|
-
this.name
|
5
|
-
|
6
|
-
if (
|
7
|
-
this.
|
8
|
-
this.
|
9
|
-
} else {
|
10
|
-
this.value = value;
|
3
|
+
tree.Directive = function (name, value, rules, index, currentFileInfo, debugInfo) {
|
4
|
+
this.name = name;
|
5
|
+
this.value = value;
|
6
|
+
if (rules) {
|
7
|
+
this.rules = rules;
|
8
|
+
this.rules.allowImports = true;
|
11
9
|
}
|
10
|
+
this.index = index;
|
11
|
+
this.currentFileInfo = currentFileInfo;
|
12
|
+
this.debugInfo = debugInfo;
|
12
13
|
};
|
14
|
+
|
13
15
|
tree.Directive.prototype = {
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
type: "Directive",
|
17
|
+
accept: function (visitor) {
|
18
|
+
var value = this.value, rules = this.rules;
|
19
|
+
if (rules) {
|
20
|
+
rules = visitor.visit(rules);
|
21
|
+
}
|
22
|
+
if (value) {
|
23
|
+
value = visitor.visit(value);
|
24
|
+
}
|
25
|
+
},
|
26
|
+
genCSS: function (env, output) {
|
27
|
+
var value = this.value, rules = this.rules;
|
28
|
+
output.add(this.name, this.currentFileInfo, this.index);
|
29
|
+
if (value) {
|
30
|
+
output.add(' ');
|
31
|
+
value.genCSS(env, output);
|
32
|
+
}
|
33
|
+
if (rules) {
|
34
|
+
tree.outputRuleset(env, output, [rules]);
|
20
35
|
} else {
|
21
|
-
|
36
|
+
output.add(';');
|
22
37
|
}
|
23
38
|
},
|
39
|
+
toCSS: tree.toCSS,
|
24
40
|
eval: function (env) {
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
41
|
+
var value = this.value, rules = this.rules;
|
42
|
+
if (value) {
|
43
|
+
value = value.eval(env);
|
44
|
+
}
|
45
|
+
if (rules) {
|
46
|
+
rules = rules.eval(env);
|
47
|
+
rules.root = true;
|
48
|
+
}
|
49
|
+
return new(tree.Directive)(this.name, value, rules,
|
50
|
+
this.index, this.currentFileInfo, this.debugInfo);
|
29
51
|
},
|
30
|
-
variable: function (name) { return tree.Ruleset.prototype.variable.call(this.
|
31
|
-
find: function () { return tree.Ruleset.prototype.find.apply(this.
|
32
|
-
rulesets: function () { return tree.Ruleset.prototype.rulesets.apply(this.
|
52
|
+
variable: function (name) { if (this.rules) return tree.Ruleset.prototype.variable.call(this.rules, name); },
|
53
|
+
find: function () { if (this.rules) return tree.Ruleset.prototype.find.apply(this.rules, arguments); },
|
54
|
+
rulesets: function () { if (this.rules) return tree.Ruleset.prototype.rulesets.apply(this.rules); },
|
55
|
+
markReferenced: function () {
|
56
|
+
var i, rules;
|
57
|
+
this.isReferenced = true;
|
58
|
+
if (this.rules) {
|
59
|
+
rules = this.rules.rules;
|
60
|
+
for (i = 0; i < rules.length; i++) {
|
61
|
+
if (rules[i].markReferenced) {
|
62
|
+
rules[i].markReferenced();
|
63
|
+
}
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}
|
33
67
|
};
|
34
68
|
|
35
69
|
})(require('../tree'));
|
@@ -1,6 +1,6 @@
|
|
1
1
|
(function (tree) {
|
2
2
|
|
3
|
-
tree.Element = function (combinator, value, index) {
|
3
|
+
tree.Element = function (combinator, value, index, currentFileInfo) {
|
4
4
|
this.combinator = combinator instanceof tree.Combinator ?
|
5
5
|
combinator : new(tree.Combinator)(combinator);
|
6
6
|
|
@@ -12,36 +12,97 @@ tree.Element = function (combinator, value, index) {
|
|
12
12
|
this.value = "";
|
13
13
|
}
|
14
14
|
this.index = index;
|
15
|
+
this.currentFileInfo = currentFileInfo;
|
15
16
|
};
|
16
|
-
tree.Element.prototype
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
tree.Element.prototype = {
|
18
|
+
type: "Element",
|
19
|
+
accept: function (visitor) {
|
20
|
+
var value = this.value;
|
21
|
+
this.combinator = visitor.visit(this.combinator);
|
22
|
+
if (typeof value === "object") {
|
23
|
+
this.value = visitor.visit(value);
|
24
|
+
}
|
25
|
+
},
|
26
|
+
eval: function (env) {
|
27
|
+
return new(tree.Element)(this.combinator,
|
28
|
+
this.value.eval ? this.value.eval(env) : this.value,
|
29
|
+
this.index,
|
30
|
+
this.currentFileInfo);
|
31
|
+
},
|
32
|
+
genCSS: function (env, output) {
|
33
|
+
output.add(this.toCSS(env), this.currentFileInfo, this.index);
|
34
|
+
},
|
35
|
+
toCSS: function (env) {
|
36
|
+
var value = (this.value.toCSS ? this.value.toCSS(env) : this.value);
|
37
|
+
if (value === '' && this.combinator.value.charAt(0) === '&') {
|
38
|
+
return '';
|
39
|
+
} else {
|
40
|
+
return this.combinator.toCSS(env || {}) + value;
|
41
|
+
}
|
42
|
+
}
|
20
43
|
};
|
21
|
-
|
22
|
-
|
44
|
+
|
45
|
+
tree.Attribute = function (key, op, value) {
|
46
|
+
this.key = key;
|
47
|
+
this.op = op;
|
48
|
+
this.value = value;
|
49
|
+
};
|
50
|
+
tree.Attribute.prototype = {
|
51
|
+
type: "Attribute",
|
52
|
+
eval: function (env) {
|
53
|
+
return new(tree.Attribute)(this.key.eval ? this.key.eval(env) : this.key,
|
54
|
+
this.op, (this.value && this.value.eval) ? this.value.eval(env) : this.value);
|
55
|
+
},
|
56
|
+
genCSS: function (env, output) {
|
57
|
+
output.add(this.toCSS(env));
|
58
|
+
},
|
59
|
+
toCSS: function (env) {
|
60
|
+
var value = this.key.toCSS ? this.key.toCSS(env) : this.key;
|
61
|
+
|
62
|
+
if (this.op) {
|
63
|
+
value += this.op;
|
64
|
+
value += (this.value.toCSS ? this.value.toCSS(env) : this.value);
|
65
|
+
}
|
66
|
+
|
67
|
+
return '[' + value + ']';
|
68
|
+
}
|
23
69
|
};
|
24
70
|
|
25
71
|
tree.Combinator = function (value) {
|
26
72
|
if (value === ' ') {
|
27
73
|
this.value = ' ';
|
28
|
-
} else if (value === '& ') {
|
29
|
-
this.value = '& ';
|
30
74
|
} else {
|
31
75
|
this.value = value ? value.trim() : "";
|
32
76
|
}
|
33
77
|
};
|
34
|
-
tree.Combinator.prototype
|
35
|
-
|
78
|
+
tree.Combinator.prototype = {
|
79
|
+
type: "Combinator",
|
80
|
+
_outputMap: {
|
81
|
+
'' : '',
|
82
|
+
' ' : ' ',
|
83
|
+
':' : ' :',
|
84
|
+
'+' : ' + ',
|
85
|
+
'~' : ' ~ ',
|
86
|
+
'>' : ' > ',
|
87
|
+
'|' : '|',
|
88
|
+
'^' : ' ^ ',
|
89
|
+
'^^' : ' ^^ '
|
90
|
+
},
|
91
|
+
_outputMapCompressed: {
|
36
92
|
'' : '',
|
37
93
|
' ' : ' ',
|
38
|
-
'&' : '',
|
39
|
-
'& ' : ' ',
|
40
94
|
':' : ' :',
|
41
|
-
'+' :
|
42
|
-
'~' :
|
43
|
-
'>' :
|
44
|
-
|
95
|
+
'+' : '+',
|
96
|
+
'~' : '~',
|
97
|
+
'>' : '>',
|
98
|
+
'|' : '|',
|
99
|
+
'^' : '^',
|
100
|
+
'^^' : '^^'
|
101
|
+
},
|
102
|
+
genCSS: function (env, output) {
|
103
|
+
output.add((env.compress ? this._outputMapCompressed : this._outputMap)[this.value]);
|
104
|
+
},
|
105
|
+
toCSS: tree.toCSS
|
45
106
|
};
|
46
107
|
|
47
108
|
})(require('../tree'));
|