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
@@ -0,0 +1,16 @@
|
|
1
|
+
(function (tree) {
|
2
|
+
|
3
|
+
tree.RulesetCall = function (variable) {
|
4
|
+
this.variable = variable;
|
5
|
+
};
|
6
|
+
tree.RulesetCall.prototype = {
|
7
|
+
type: "RulesetCall",
|
8
|
+
accept: function (visitor) {
|
9
|
+
},
|
10
|
+
eval: function (env) {
|
11
|
+
var detachedRuleset = new(tree.Variable)(this.variable).eval(env);
|
12
|
+
return detachedRuleset.callEval(env);
|
13
|
+
}
|
14
|
+
};
|
15
|
+
|
16
|
+
})(require('../tree'));
|
@@ -7,95 +7,252 @@ tree.Ruleset = function (selectors, rules, strictImports) {
|
|
7
7
|
this.strictImports = strictImports;
|
8
8
|
};
|
9
9
|
tree.Ruleset.prototype = {
|
10
|
+
type: "Ruleset",
|
11
|
+
accept: function (visitor) {
|
12
|
+
if (this.paths) {
|
13
|
+
visitor.visitArray(this.paths, true);
|
14
|
+
} else if (this.selectors) {
|
15
|
+
this.selectors = visitor.visitArray(this.selectors);
|
16
|
+
}
|
17
|
+
if (this.rules && this.rules.length) {
|
18
|
+
this.rules = visitor.visitArray(this.rules);
|
19
|
+
}
|
20
|
+
},
|
10
21
|
eval: function (env) {
|
11
|
-
var
|
12
|
-
|
22
|
+
var thisSelectors = this.selectors, selectors,
|
23
|
+
selCnt, selector, i, defaultFunc = tree.defaultFunc, hasOnePassingSelector = false;
|
24
|
+
|
25
|
+
if (thisSelectors && (selCnt = thisSelectors.length)) {
|
26
|
+
selectors = [];
|
27
|
+
defaultFunc.error({
|
28
|
+
type: "Syntax",
|
29
|
+
message: "it is currently only allowed in parametric mixin guards,"
|
30
|
+
});
|
31
|
+
for (i = 0; i < selCnt; i++) {
|
32
|
+
selector = thisSelectors[i].eval(env);
|
33
|
+
selectors.push(selector);
|
34
|
+
if (selector.evaldCondition) {
|
35
|
+
hasOnePassingSelector = true;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
defaultFunc.reset();
|
39
|
+
} else {
|
40
|
+
hasOnePassingSelector = true;
|
41
|
+
}
|
42
|
+
|
43
|
+
var rules = this.rules ? this.rules.slice(0) : null,
|
44
|
+
ruleset = new(tree.Ruleset)(selectors, rules, this.strictImports),
|
45
|
+
rule, subRule;
|
13
46
|
|
47
|
+
ruleset.originalRuleset = this;
|
14
48
|
ruleset.root = this.root;
|
49
|
+
ruleset.firstRoot = this.firstRoot;
|
15
50
|
ruleset.allowImports = this.allowImports;
|
16
51
|
|
52
|
+
if(this.debugInfo) {
|
53
|
+
ruleset.debugInfo = this.debugInfo;
|
54
|
+
}
|
55
|
+
|
56
|
+
if (!hasOnePassingSelector) {
|
57
|
+
rules.length = 0;
|
58
|
+
}
|
59
|
+
|
17
60
|
// push the current ruleset to the frames stack
|
18
|
-
env.frames
|
61
|
+
var envFrames = env.frames;
|
62
|
+
envFrames.unshift(ruleset);
|
63
|
+
|
64
|
+
// currrent selectors
|
65
|
+
var envSelectors = env.selectors;
|
66
|
+
if (!envSelectors) {
|
67
|
+
env.selectors = envSelectors = [];
|
68
|
+
}
|
69
|
+
envSelectors.unshift(this.selectors);
|
19
70
|
|
20
71
|
// Evaluate imports
|
21
72
|
if (ruleset.root || ruleset.allowImports || !ruleset.strictImports) {
|
22
|
-
|
23
|
-
if (ruleset.rules[i] instanceof tree.Import) {
|
24
|
-
Array.prototype.splice
|
25
|
-
.apply(ruleset.rules, [i, 1].concat(ruleset.rules[i].eval(env)));
|
26
|
-
}
|
27
|
-
}
|
73
|
+
ruleset.evalImports(env);
|
28
74
|
}
|
29
75
|
|
30
76
|
// Store the frames around mixin definitions,
|
31
77
|
// so they can be evaluated like closures when the time comes.
|
32
|
-
|
33
|
-
|
34
|
-
|
78
|
+
var rsRules = ruleset.rules, rsRuleCnt = rsRules ? rsRules.length : 0;
|
79
|
+
for (i = 0; i < rsRuleCnt; i++) {
|
80
|
+
if (rsRules[i] instanceof tree.mixin.Definition || rsRules[i] instanceof tree.DetachedRuleset) {
|
81
|
+
rsRules[i] = rsRules[i].eval(env);
|
35
82
|
}
|
36
83
|
}
|
37
84
|
|
85
|
+
var mediaBlockCount = (env.mediaBlocks && env.mediaBlocks.length) || 0;
|
86
|
+
|
38
87
|
// Evaluate mixin calls.
|
39
|
-
for (
|
40
|
-
if (
|
41
|
-
|
42
|
-
|
88
|
+
for (i = 0; i < rsRuleCnt; i++) {
|
89
|
+
if (rsRules[i] instanceof tree.mixin.Call) {
|
90
|
+
/*jshint loopfunc:true */
|
91
|
+
rules = rsRules[i].eval(env).filter(function(r) {
|
92
|
+
if ((r instanceof tree.Rule) && r.variable) {
|
93
|
+
// do not pollute the scope if the variable is
|
94
|
+
// already there. consider returning false here
|
95
|
+
// but we need a way to "return" variable from mixins
|
96
|
+
return !(ruleset.variable(r.name));
|
97
|
+
}
|
98
|
+
return true;
|
99
|
+
});
|
100
|
+
rsRules.splice.apply(rsRules, [i, 1].concat(rules));
|
101
|
+
rsRuleCnt += rules.length - 1;
|
102
|
+
i += rules.length-1;
|
103
|
+
ruleset.resetCache();
|
104
|
+
} else if (rsRules[i] instanceof tree.RulesetCall) {
|
105
|
+
/*jshint loopfunc:true */
|
106
|
+
rules = rsRules[i].eval(env).rules.filter(function(r) {
|
107
|
+
if ((r instanceof tree.Rule) && r.variable) {
|
108
|
+
// do not pollute the scope at all
|
109
|
+
return false;
|
110
|
+
}
|
111
|
+
return true;
|
112
|
+
});
|
113
|
+
rsRules.splice.apply(rsRules, [i, 1].concat(rules));
|
114
|
+
rsRuleCnt += rules.length - 1;
|
115
|
+
i += rules.length-1;
|
116
|
+
ruleset.resetCache();
|
43
117
|
}
|
44
118
|
}
|
45
119
|
|
46
120
|
// Evaluate everything else
|
47
|
-
for (
|
48
|
-
rule =
|
121
|
+
for (i = 0; i < rsRules.length; i++) {
|
122
|
+
rule = rsRules[i];
|
123
|
+
if (! (rule instanceof tree.mixin.Definition || rule instanceof tree.DetachedRuleset)) {
|
124
|
+
rsRules[i] = rule = rule.eval ? rule.eval(env) : rule;
|
125
|
+
}
|
126
|
+
}
|
127
|
+
|
128
|
+
// Evaluate everything else
|
129
|
+
for (i = 0; i < rsRules.length; i++) {
|
130
|
+
rule = rsRules[i];
|
131
|
+
// for rulesets, check if it is a css guard and can be removed
|
132
|
+
if (rule instanceof tree.Ruleset && rule.selectors && rule.selectors.length === 1) {
|
133
|
+
// check if it can be folded in (e.g. & where)
|
134
|
+
if (rule.selectors[0].isJustParentSelector()) {
|
135
|
+
rsRules.splice(i--, 1);
|
49
136
|
|
50
|
-
|
51
|
-
|
137
|
+
for(var j = 0; j < rule.rules.length; j++) {
|
138
|
+
subRule = rule.rules[j];
|
139
|
+
if (!(subRule instanceof tree.Rule) || !subRule.variable) {
|
140
|
+
rsRules.splice(++i, 0, subRule);
|
141
|
+
}
|
142
|
+
}
|
143
|
+
}
|
52
144
|
}
|
53
145
|
}
|
54
146
|
|
55
147
|
// Pop the stack
|
56
|
-
|
148
|
+
envFrames.shift();
|
149
|
+
envSelectors.shift();
|
150
|
+
|
151
|
+
if (env.mediaBlocks) {
|
152
|
+
for (i = mediaBlockCount; i < env.mediaBlocks.length; i++) {
|
153
|
+
env.mediaBlocks[i].bubbleSelectors(selectors);
|
154
|
+
}
|
155
|
+
}
|
57
156
|
|
58
157
|
return ruleset;
|
59
158
|
},
|
60
|
-
|
159
|
+
evalImports: function(env) {
|
160
|
+
var rules = this.rules, i, importRules;
|
161
|
+
if (!rules) { return; }
|
162
|
+
|
163
|
+
for (i = 0; i < rules.length; i++) {
|
164
|
+
if (rules[i] instanceof tree.Import) {
|
165
|
+
importRules = rules[i].eval(env);
|
166
|
+
if (importRules && importRules.length) {
|
167
|
+
rules.splice.apply(rules, [i, 1].concat(importRules));
|
168
|
+
i+= importRules.length-1;
|
169
|
+
} else {
|
170
|
+
rules.splice(i, 1, importRules);
|
171
|
+
}
|
172
|
+
this.resetCache();
|
173
|
+
}
|
174
|
+
}
|
175
|
+
},
|
176
|
+
makeImportant: function() {
|
177
|
+
return new tree.Ruleset(this.selectors, this.rules.map(function (r) {
|
178
|
+
if (r.makeImportant) {
|
179
|
+
return r.makeImportant();
|
180
|
+
} else {
|
181
|
+
return r;
|
182
|
+
}
|
183
|
+
}), this.strictImports);
|
184
|
+
},
|
185
|
+
matchArgs: function (args) {
|
61
186
|
return !args || args.length === 0;
|
62
187
|
},
|
188
|
+
// lets you call a css selector with a guard
|
189
|
+
matchCondition: function (args, env) {
|
190
|
+
var lastSelector = this.selectors[this.selectors.length-1];
|
191
|
+
if (!lastSelector.evaldCondition) {
|
192
|
+
return false;
|
193
|
+
}
|
194
|
+
if (lastSelector.condition &&
|
195
|
+
!lastSelector.condition.eval(
|
196
|
+
new(tree.evalEnv)(env,
|
197
|
+
env.frames))) {
|
198
|
+
return false;
|
199
|
+
}
|
200
|
+
return true;
|
201
|
+
},
|
202
|
+
resetCache: function () {
|
203
|
+
this._rulesets = null;
|
204
|
+
this._variables = null;
|
205
|
+
this._lookups = {};
|
206
|
+
},
|
63
207
|
variables: function () {
|
64
|
-
if (this._variables) {
|
65
|
-
|
66
|
-
return this._variables = this.rules.reduce(function (hash, r) {
|
208
|
+
if (!this._variables) {
|
209
|
+
this._variables = !this.rules ? {} : this.rules.reduce(function (hash, r) {
|
67
210
|
if (r instanceof tree.Rule && r.variable === true) {
|
68
211
|
hash[r.name] = r;
|
69
212
|
}
|
70
213
|
return hash;
|
71
214
|
}, {});
|
72
215
|
}
|
216
|
+
return this._variables;
|
73
217
|
},
|
74
218
|
variable: function (name) {
|
75
219
|
return this.variables()[name];
|
76
220
|
},
|
77
221
|
rulesets: function () {
|
78
|
-
if (this.
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
222
|
+
if (!this.rules) { return null; }
|
223
|
+
|
224
|
+
var _Ruleset = tree.Ruleset, _MixinDefinition = tree.mixin.Definition,
|
225
|
+
filtRules = [], rules = this.rules, cnt = rules.length,
|
226
|
+
i, rule;
|
227
|
+
|
228
|
+
for (i = 0; i < cnt; i++) {
|
229
|
+
rule = rules[i];
|
230
|
+
if ((rule instanceof _Ruleset) || (rule instanceof _MixinDefinition)) {
|
231
|
+
filtRules.push(rule);
|
232
|
+
}
|
83
233
|
}
|
234
|
+
|
235
|
+
return filtRules;
|
236
|
+
},
|
237
|
+
prependRule: function (rule) {
|
238
|
+
var rules = this.rules;
|
239
|
+
if (rules) { rules.unshift(rule); } else { this.rules = [ rule ]; }
|
84
240
|
},
|
85
241
|
find: function (selector, self) {
|
86
242
|
self = self || this;
|
87
|
-
var rules = [],
|
243
|
+
var rules = [], match,
|
88
244
|
key = selector.toCSS();
|
89
245
|
|
90
|
-
if (key in this._lookups) { return this._lookups[key] }
|
246
|
+
if (key in this._lookups) { return this._lookups[key]; }
|
91
247
|
|
92
248
|
this.rulesets().forEach(function (rule) {
|
93
249
|
if (rule !== self) {
|
94
250
|
for (var j = 0; j < rule.selectors.length; j++) {
|
95
|
-
|
96
|
-
|
251
|
+
match = selector.match(rule.selectors[j]);
|
252
|
+
if (match) {
|
253
|
+
if (selector.elements.length > match) {
|
97
254
|
Array.prototype.push.apply(rules, rule.find(
|
98
|
-
new(tree.Selector)(selector.elements.slice(
|
255
|
+
new(tree.Selector)(selector.elements.slice(match)), self));
|
99
256
|
} else {
|
100
257
|
rules.push(rule);
|
101
258
|
}
|
@@ -104,76 +261,122 @@ tree.Ruleset.prototype = {
|
|
104
261
|
}
|
105
262
|
}
|
106
263
|
});
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
264
|
+
this._lookups[key] = rules;
|
265
|
+
return rules;
|
266
|
+
},
|
267
|
+
genCSS: function (env, output) {
|
268
|
+
var i, j,
|
269
|
+
ruleNodes = [],
|
270
|
+
rulesetNodes = [],
|
271
|
+
rulesetNodeCnt,
|
272
|
+
debugInfo, // Line number debugging
|
273
|
+
rule,
|
274
|
+
path;
|
275
|
+
|
276
|
+
env.tabLevel = (env.tabLevel || 0);
|
277
|
+
|
278
|
+
if (!this.root) {
|
279
|
+
env.tabLevel++;
|
280
|
+
}
|
281
|
+
|
282
|
+
var tabRuleStr = env.compress ? '' : Array(env.tabLevel + 1).join(" "),
|
283
|
+
tabSetStr = env.compress ? '' : Array(env.tabLevel).join(" "),
|
284
|
+
sep;
|
285
|
+
|
286
|
+
for (i = 0; i < this.rules.length; i++) {
|
287
|
+
rule = this.rules[i];
|
288
|
+
if (rule.rules || (rule instanceof tree.Media) || rule instanceof tree.Directive || (this.root && rule instanceof tree.Comment)) {
|
289
|
+
rulesetNodes.push(rule);
|
125
290
|
} else {
|
126
|
-
|
291
|
+
ruleNodes.push(rule);
|
127
292
|
}
|
128
293
|
}
|
129
294
|
|
130
|
-
//
|
131
|
-
|
132
|
-
|
295
|
+
// If this is the root node, we don't render
|
296
|
+
// a selector, or {}.
|
297
|
+
if (!this.root) {
|
298
|
+
debugInfo = tree.debugInfo(env, this, tabSetStr);
|
133
299
|
|
134
|
-
if (
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
300
|
+
if (debugInfo) {
|
301
|
+
output.add(debugInfo);
|
302
|
+
output.add(tabSetStr);
|
303
|
+
}
|
304
|
+
|
305
|
+
var paths = this.paths, pathCnt = paths.length,
|
306
|
+
pathSubCnt;
|
307
|
+
|
308
|
+
sep = env.compress ? ',' : (',\n' + tabSetStr);
|
309
|
+
|
310
|
+
for (i = 0; i < pathCnt; i++) {
|
311
|
+
path = paths[i];
|
312
|
+
if (!(pathSubCnt = path.length)) { continue; }
|
313
|
+
if (i > 0) { output.add(sep); }
|
314
|
+
|
315
|
+
env.firstSelector = true;
|
316
|
+
path[0].genCSS(env, output);
|
317
|
+
|
318
|
+
env.firstSelector = false;
|
319
|
+
for (j = 1; j < pathSubCnt; j++) {
|
320
|
+
path[j].genCSS(env, output);
|
149
321
|
}
|
150
322
|
}
|
151
|
-
}
|
152
323
|
|
153
|
-
|
324
|
+
output.add((env.compress ? '{' : ' {\n') + tabRuleStr);
|
325
|
+
}
|
154
326
|
|
155
|
-
//
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
if (
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
327
|
+
// Compile rules and rulesets
|
328
|
+
for (i = 0; i < ruleNodes.length; i++) {
|
329
|
+
rule = ruleNodes[i];
|
330
|
+
|
331
|
+
// @page{ directive ends up with root elements inside it, a mix of rules and rulesets
|
332
|
+
// In this instance we do not know whether it is the last property
|
333
|
+
if (i + 1 === ruleNodes.length && (!this.root || rulesetNodes.length === 0 || this.firstRoot)) {
|
334
|
+
env.lastRule = true;
|
335
|
+
}
|
336
|
+
|
337
|
+
if (rule.genCSS) {
|
338
|
+
rule.genCSS(env, output);
|
339
|
+
} else if (rule.value) {
|
340
|
+
output.add(rule.value.toString());
|
341
|
+
}
|
167
342
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
343
|
+
if (!env.lastRule) {
|
344
|
+
output.add(env.compress ? '' : ('\n' + tabRuleStr));
|
345
|
+
} else {
|
346
|
+
env.lastRule = false;
|
347
|
+
}
|
348
|
+
}
|
349
|
+
|
350
|
+
if (!this.root) {
|
351
|
+
output.add((env.compress ? '}' : '\n' + tabSetStr + '}'));
|
352
|
+
env.tabLevel--;
|
353
|
+
}
|
354
|
+
|
355
|
+
sep = (env.compress ? "" : "\n") + (this.root ? tabRuleStr : tabSetStr);
|
356
|
+
rulesetNodeCnt = rulesetNodes.length;
|
357
|
+
if (rulesetNodeCnt) {
|
358
|
+
if (ruleNodes.length && sep) { output.add(sep); }
|
359
|
+
rulesetNodes[0].genCSS(env, output);
|
360
|
+
for (i = 1; i < rulesetNodeCnt; i++) {
|
361
|
+
if (sep) { output.add(sep); }
|
362
|
+
rulesetNodes[i].genCSS(env, output);
|
172
363
|
}
|
173
364
|
}
|
174
|
-
css.push(rulesets);
|
175
365
|
|
176
|
-
|
366
|
+
if (!output.isEmpty() && !env.compress && this.firstRoot) {
|
367
|
+
output.add('\n');
|
368
|
+
}
|
369
|
+
},
|
370
|
+
|
371
|
+
toCSS: tree.toCSS,
|
372
|
+
|
373
|
+
markReferenced: function () {
|
374
|
+
if (!this.selectors) {
|
375
|
+
return;
|
376
|
+
}
|
377
|
+
for (var s = 0; s < this.selectors.length; s++) {
|
378
|
+
this.selectors[s].markReferenced();
|
379
|
+
}
|
177
380
|
},
|
178
381
|
|
179
382
|
joinSelectors: function (paths, context, selectors) {
|
@@ -183,33 +386,168 @@ tree.Ruleset.prototype = {
|
|
183
386
|
},
|
184
387
|
|
185
388
|
joinSelector: function (paths, context, selector) {
|
186
|
-
var before = [], after = [], beforeElements = [],
|
187
|
-
afterElements = [], hasParentSelector = false, el;
|
188
389
|
|
189
|
-
|
390
|
+
var i, j, k,
|
391
|
+
hasParentSelector, newSelectors, el, sel, parentSel,
|
392
|
+
newSelectorPath, afterParentJoin, newJoinedSelector,
|
393
|
+
newJoinedSelectorEmpty, lastSelector, currentElements,
|
394
|
+
selectorsMultiplied;
|
395
|
+
|
396
|
+
for (i = 0; i < selector.elements.length; i++) {
|
190
397
|
el = selector.elements[i];
|
191
|
-
if (el.
|
398
|
+
if (el.value === '&') {
|
192
399
|
hasParentSelector = true;
|
193
400
|
}
|
194
|
-
|
195
|
-
|
401
|
+
}
|
402
|
+
|
403
|
+
if (!hasParentSelector) {
|
404
|
+
if (context.length > 0) {
|
405
|
+
for (i = 0; i < context.length; i++) {
|
406
|
+
paths.push(context[i].concat(selector));
|
407
|
+
}
|
408
|
+
}
|
409
|
+
else {
|
410
|
+
paths.push([selector]);
|
411
|
+
}
|
412
|
+
return;
|
413
|
+
}
|
414
|
+
|
415
|
+
// The paths are [[Selector]]
|
416
|
+
// The first list is a list of comma seperated selectors
|
417
|
+
// The inner list is a list of inheritance seperated selectors
|
418
|
+
// e.g.
|
419
|
+
// .a, .b {
|
420
|
+
// .c {
|
421
|
+
// }
|
422
|
+
// }
|
423
|
+
// == [[.a] [.c]] [[.b] [.c]]
|
424
|
+
//
|
425
|
+
|
426
|
+
// the elements from the current selector so far
|
427
|
+
currentElements = [];
|
428
|
+
// the current list of new selectors to add to the path.
|
429
|
+
// We will build it up. We initiate it with one empty selector as we "multiply" the new selectors
|
430
|
+
// by the parents
|
431
|
+
newSelectors = [[]];
|
432
|
+
|
433
|
+
for (i = 0; i < selector.elements.length; i++) {
|
434
|
+
el = selector.elements[i];
|
435
|
+
// non parent reference elements just get added
|
436
|
+
if (el.value !== "&") {
|
437
|
+
currentElements.push(el);
|
438
|
+
} else {
|
439
|
+
// the new list of selectors to add
|
440
|
+
selectorsMultiplied = [];
|
441
|
+
|
442
|
+
// merge the current list of non parent selector elements
|
443
|
+
// on to the current list of selectors to add
|
444
|
+
if (currentElements.length > 0) {
|
445
|
+
this.mergeElementsOnToSelectors(currentElements, newSelectors);
|
446
|
+
}
|
447
|
+
|
448
|
+
// loop through our current selectors
|
449
|
+
for (j = 0; j < newSelectors.length; j++) {
|
450
|
+
sel = newSelectors[j];
|
451
|
+
// if we don't have any parent paths, the & might be in a mixin so that it can be used
|
452
|
+
// whether there are parents or not
|
453
|
+
if (context.length === 0) {
|
454
|
+
// the combinator used on el should now be applied to the next element instead so that
|
455
|
+
// it is not lost
|
456
|
+
if (sel.length > 0) {
|
457
|
+
sel[0].elements = sel[0].elements.slice(0);
|
458
|
+
sel[0].elements.push(new(tree.Element)(el.combinator, '', el.index, el.currentFileInfo));
|
459
|
+
}
|
460
|
+
selectorsMultiplied.push(sel);
|
461
|
+
}
|
462
|
+
else {
|
463
|
+
// and the parent selectors
|
464
|
+
for (k = 0; k < context.length; k++) {
|
465
|
+
parentSel = context[k];
|
466
|
+
// We need to put the current selectors
|
467
|
+
// then join the last selector's elements on to the parents selectors
|
468
|
+
|
469
|
+
// our new selector path
|
470
|
+
newSelectorPath = [];
|
471
|
+
// selectors from the parent after the join
|
472
|
+
afterParentJoin = [];
|
473
|
+
newJoinedSelectorEmpty = true;
|
474
|
+
|
475
|
+
//construct the joined selector - if & is the first thing this will be empty,
|
476
|
+
// if not newJoinedSelector will be the last set of elements in the selector
|
477
|
+
if (sel.length > 0) {
|
478
|
+
newSelectorPath = sel.slice(0);
|
479
|
+
lastSelector = newSelectorPath.pop();
|
480
|
+
newJoinedSelector = selector.createDerived(lastSelector.elements.slice(0));
|
481
|
+
newJoinedSelectorEmpty = false;
|
482
|
+
}
|
483
|
+
else {
|
484
|
+
newJoinedSelector = selector.createDerived([]);
|
485
|
+
}
|
486
|
+
|
487
|
+
//put together the parent selectors after the join
|
488
|
+
if (parentSel.length > 1) {
|
489
|
+
afterParentJoin = afterParentJoin.concat(parentSel.slice(1));
|
490
|
+
}
|
491
|
+
|
492
|
+
if (parentSel.length > 0) {
|
493
|
+
newJoinedSelectorEmpty = false;
|
494
|
+
|
495
|
+
// join the elements so far with the first part of the parent
|
496
|
+
newJoinedSelector.elements.push(new(tree.Element)(el.combinator, parentSel[0].elements[0].value, el.index, el.currentFileInfo));
|
497
|
+
newJoinedSelector.elements = newJoinedSelector.elements.concat(parentSel[0].elements.slice(1));
|
498
|
+
}
|
499
|
+
|
500
|
+
if (!newJoinedSelectorEmpty) {
|
501
|
+
// now add the joined selector
|
502
|
+
newSelectorPath.push(newJoinedSelector);
|
503
|
+
}
|
504
|
+
|
505
|
+
// and the rest of the parent
|
506
|
+
newSelectorPath = newSelectorPath.concat(afterParentJoin);
|
507
|
+
|
508
|
+
// add that to our new set of selectors
|
509
|
+
selectorsMultiplied.push(newSelectorPath);
|
510
|
+
}
|
511
|
+
}
|
512
|
+
}
|
513
|
+
|
514
|
+
// our new selectors has been multiplied, so reset the state
|
515
|
+
newSelectors = selectorsMultiplied;
|
516
|
+
currentElements = [];
|
517
|
+
}
|
196
518
|
}
|
197
519
|
|
198
|
-
if (
|
199
|
-
|
200
|
-
|
520
|
+
// if we have any elements left over (e.g. .a& .b == .b)
|
521
|
+
// add them on to all the current selectors
|
522
|
+
if (currentElements.length > 0) {
|
523
|
+
this.mergeElementsOnToSelectors(currentElements, newSelectors);
|
201
524
|
}
|
202
525
|
|
203
|
-
|
204
|
-
|
526
|
+
for (i = 0; i < newSelectors.length; i++) {
|
527
|
+
if (newSelectors[i].length > 0) {
|
528
|
+
paths.push(newSelectors[i]);
|
529
|
+
}
|
205
530
|
}
|
531
|
+
},
|
532
|
+
|
533
|
+
mergeElementsOnToSelectors: function(elements, selectors) {
|
534
|
+
var i, sel;
|
206
535
|
|
207
|
-
if (
|
208
|
-
|
536
|
+
if (selectors.length === 0) {
|
537
|
+
selectors.push([ new(tree.Selector)(elements) ]);
|
538
|
+
return;
|
209
539
|
}
|
210
540
|
|
211
|
-
for (
|
212
|
-
|
541
|
+
for (i = 0; i < selectors.length; i++) {
|
542
|
+
sel = selectors[i];
|
543
|
+
|
544
|
+
// if the previous thing in sel is a parent this needs to join on to it
|
545
|
+
if (sel.length > 0) {
|
546
|
+
sel[sel.length - 1] = sel[sel.length - 1].createDerived(sel[sel.length - 1].elements.concat(elements));
|
547
|
+
}
|
548
|
+
else {
|
549
|
+
sel.push(new(tree.Selector)(elements));
|
550
|
+
}
|
213
551
|
}
|
214
552
|
}
|
215
553
|
};
|