less-execjs 2.6.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +7 -0
- data/.gitmodules +9 -0
- data/.rubocop.yml +8 -0
- data/.travis.yml +19 -0
- data/Gemfile +3 -0
- data/LICENSE +177 -0
- data/README.md +55 -0
- data/Rakefile +8 -0
- data/bin/lessc +22 -0
- data/less-execjs.gemspec +34 -0
- data/lib/less-execjs.rb +1 -0
- data/lib/less.rb +29 -0
- data/lib/less/compiler.js +24 -0
- data/lib/less/defaults.rb +15 -0
- data/lib/less/errors.rb +16 -0
- data/lib/less/js/image-size.js +4 -0
- data/lib/less/js/image-size/.gitignore +7 -0
- data/lib/less/js/image-size/.jshintrc +19 -0
- data/lib/less/js/image-size/.travis.yml +12 -0
- data/lib/less/js/image-size/Contributors.md +9 -0
- data/lib/less/js/image-size/LICENSE +9 -0
- data/lib/less/js/image-size/Readme.md +87 -0
- data/lib/less/js/image-size/bin/image-size.js +36 -0
- data/lib/less/js/image-size/lib/detector.js +19 -0
- data/lib/less/js/image-size/lib/index.js +104 -0
- data/lib/less/js/image-size/lib/readUInt.js +11 -0
- data/lib/less/js/image-size/lib/types.js +12 -0
- data/lib/less/js/image-size/lib/types/bmp.js +17 -0
- data/lib/less/js/image-size/lib/types/gif.js +19 -0
- data/lib/less/js/image-size/lib/types/jpg.js +62 -0
- data/lib/less/js/image-size/lib/types/png.js +23 -0
- data/lib/less/js/image-size/lib/types/psd.js +17 -0
- data/lib/less/js/image-size/lib/types/svg.js +78 -0
- data/lib/less/js/image-size/lib/types/tiff.js +118 -0
- data/lib/less/js/image-size/lib/types/webp.js +51 -0
- data/lib/less/js/image-size/package.json +49 -0
- data/lib/less/js/image-size/specs/.jshintrc +9 -0
- data/lib/less/js/image-size/specs/complexity.js +58 -0
- data/lib/less/js/image-size/specs/fs-close.spec.js +61 -0
- data/lib/less/js/image-size/specs/images/invalid/malformed.svg +1 -0
- data/lib/less/js/image-size/specs/images/invalid/sample.png +0 -0
- data/lib/less/js/image-size/specs/images/invalid/width.svg +1 -0
- data/lib/less/js/image-size/specs/images/valid/bmp/sample.bmp +0 -0
- data/lib/less/js/image-size/specs/images/valid/gif/sample.gif +0 -0
- data/lib/less/js/image-size/specs/images/valid/jpg/large.jpg +0 -0
- data/lib/less/js/image-size/specs/images/valid/jpg/progressive.jpg +0 -0
- data/lib/less/js/image-size/specs/images/valid/jpg/sample.jpg +0 -0
- data/lib/less/js/image-size/specs/images/valid/jpg/sampleExported.jpg +0 -0
- data/lib/less/js/image-size/specs/images/valid/jpg/very-large.jpg +0 -0
- data/lib/less/js/image-size/specs/images/valid/png/sample.png +0 -0
- data/lib/less/js/image-size/specs/images/valid/psd/sample.psd +0 -0
- data/lib/less/js/image-size/specs/images/valid/svg/percentage.svg +4 -0
- data/lib/less/js/image-size/specs/images/valid/svg/single-quotes.svg +5 -0
- data/lib/less/js/image-size/specs/images/valid/svg/viewbox-height.svg +4 -0
- data/lib/less/js/image-size/specs/images/valid/svg/viewbox-width-height.svg +4 -0
- data/lib/less/js/image-size/specs/images/valid/svg/viewbox-width.svg +4 -0
- data/lib/less/js/image-size/specs/images/valid/svg/viewbox.svg +4 -0
- data/lib/less/js/image-size/specs/images/valid/svg/width-height.svg +5 -0
- data/lib/less/js/image-size/specs/images/valid/tiff/big-endian.tiff +0 -0
- data/lib/less/js/image-size/specs/images/valid/tiff/jpeg.tiff +0 -0
- data/lib/less/js/image-size/specs/images/valid/tiff/little-endian.tiff +0 -0
- data/lib/less/js/image-size/specs/images/valid/webp/lossless.webp +0 -0
- data/lib/less/js/image-size/specs/images/valid/webp/lossy.webp +0 -0
- data/lib/less/js/image-size/specs/invalid.spec.js +53 -0
- data/lib/less/js/image-size/specs/others.spec.js +77 -0
- data/lib/less/js/image-size/specs/unsupported.spec.js +34 -0
- data/lib/less/js/image-size/specs/valid.spec.js +75 -0
- data/lib/less/js/less/.gitattributes +11 -0
- data/lib/less/js/less/.gitignore +27 -0
- data/lib/less/js/less/.jscsrc +73 -0
- data/lib/less/js/less/.jshintrc +11 -0
- data/lib/less/js/less/.npmignore +9 -0
- data/lib/less/js/less/.travis.yml +14 -0
- data/lib/less/js/less/CHANGELOG.md +561 -0
- data/lib/less/js/less/CONTRIBUTING.md +50 -0
- data/lib/less/js/less/Gruntfile.js +459 -0
- data/lib/less/js/less/LICENSE +177 -0
- data/lib/less/js/less/README.md +56 -0
- data/lib/less/js/less/appveyor.yml +32 -0
- data/lib/less/js/less/benchmark/benchmark.less +3979 -0
- data/lib/less/js/less/benchmark/index.js +55 -0
- data/lib/less/js/less/bin/lessc +488 -0
- data/lib/less/js/less/bower.json +24 -0
- data/lib/less/js/less/browser.js +1 -0
- data/lib/less/js/less/build.gradle +347 -0
- data/lib/less/js/less/build/amd.js +6 -0
- data/lib/less/js/less/build/build.yml +130 -0
- data/lib/less/js/less/build/require-rhino.js +12 -0
- data/lib/less/js/less/build/rhino-header.js +4 -0
- data/lib/less/js/less/build/rhino-modules.js +131 -0
- data/lib/less/js/less/build/tasks/.gitkeep +1 -0
- data/lib/less/js/less/dist/less.js +10500 -0
- data/lib/less/js/less/dist/less.min.js +20 -0
- data/lib/less/js/less/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/lib/less/js/less/gradle/wrapper/gradle-wrapper.properties +6 -0
- data/lib/less/js/less/gradlew +164 -0
- data/lib/less/js/less/gradlew.bat +90 -0
- data/lib/less/js/less/index.js +1 -0
- data/lib/less/js/less/lib/less-browser/add-default-options.js +46 -0
- data/lib/less/js/less/lib/less-browser/bootstrap.js +51 -0
- data/lib/less/js/less/lib/less-browser/browser.js +64 -0
- data/lib/less/js/less/lib/less-browser/cache.js +42 -0
- data/lib/less/js/less/lib/less-browser/error-reporting.js +170 -0
- data/lib/less/js/less/lib/less-browser/file-manager.js +119 -0
- data/lib/less/js/less/lib/less-browser/image-size.js +28 -0
- data/lib/less/js/less/lib/less-browser/index.js +263 -0
- data/lib/less/js/less/lib/less-browser/log-listener.js +43 -0
- data/lib/less/js/less/lib/less-browser/utils.js +24 -0
- data/lib/less/js/less/lib/less-node/environment.js +14 -0
- data/lib/less/js/less/lib/less-node/file-manager.js +108 -0
- data/lib/less/js/less/lib/less-node/fs.js +10 -0
- data/lib/less/js/less/lib/less-node/image-size.js +57 -0
- data/lib/less/js/less/lib/less-node/index.js +74 -0
- data/lib/less/js/less/lib/less-node/lessc-helper.js +82 -0
- data/lib/less/js/less/lib/less-node/plugin-loader.js +91 -0
- data/lib/less/js/less/lib/less-node/url-file-manager.js +56 -0
- data/lib/less/js/less/lib/less-rhino/index.js +450 -0
- data/lib/less/js/less/lib/less/contexts.js +111 -0
- data/lib/less/js/less/lib/less/data/colors.js +150 -0
- data/lib/less/js/less/lib/less/data/index.js +4 -0
- data/lib/less/js/less/lib/less/data/unit-conversions.js +21 -0
- data/lib/less/js/less/lib/less/environment/abstract-file-manager.js +123 -0
- data/lib/less/js/less/lib/less/environment/environment-api.js +25 -0
- data/lib/less/js/less/lib/less/environment/environment.js +51 -0
- data/lib/less/js/less/lib/less/environment/file-manager-api.js +103 -0
- data/lib/less/js/less/lib/less/functions/color-blending.js +74 -0
- data/lib/less/js/less/lib/less/functions/color.js +322 -0
- data/lib/less/js/less/lib/less/functions/data-uri.js +85 -0
- data/lib/less/js/less/lib/less/functions/default.js +27 -0
- data/lib/less/js/less/lib/less/functions/function-caller.js +46 -0
- data/lib/less/js/less/lib/less/functions/function-registry.js +29 -0
- data/lib/less/js/less/lib/less/functions/index.js +19 -0
- data/lib/less/js/less/lib/less/functions/math-helper.js +16 -0
- data/lib/less/js/less/lib/less/functions/math.js +29 -0
- data/lib/less/js/less/lib/less/functions/number.js +81 -0
- data/lib/less/js/less/lib/less/functions/string.js +37 -0
- data/lib/less/js/less/lib/less/functions/svg.js +88 -0
- data/lib/less/js/less/lib/less/functions/types.js +89 -0
- data/lib/less/js/less/lib/less/import-manager.js +131 -0
- data/lib/less/js/less/lib/less/index.js +29 -0
- data/lib/less/js/less/lib/less/less-error.js +42 -0
- data/lib/less/js/less/lib/less/logger.js +34 -0
- data/lib/less/js/less/lib/less/parse-tree.js +60 -0
- data/lib/less/js/less/lib/less/parse.js +68 -0
- data/lib/less/js/less/lib/less/parser/chunker.js +112 -0
- data/lib/less/js/less/lib/less/parser/parser-input.js +259 -0
- data/lib/less/js/less/lib/less/parser/parser.js +1851 -0
- data/lib/less/js/less/lib/less/plugin-manager.js +114 -0
- data/lib/less/js/less/lib/less/plugins/function-importer.js +35 -0
- data/lib/less/js/less/lib/less/render.js +41 -0
- data/lib/less/js/less/lib/less/source-map-builder.js +69 -0
- data/lib/less/js/less/lib/less/source-map-output.js +138 -0
- data/lib/less/js/less/lib/less/transform-tree.js +74 -0
- data/lib/less/js/less/lib/less/tree/alpha.js +28 -0
- data/lib/less/js/less/lib/less/tree/anonymous.js +26 -0
- data/lib/less/js/less/lib/less/tree/assignment.js +27 -0
- data/lib/less/js/less/lib/less/tree/attribute.js +27 -0
- data/lib/less/js/less/lib/less/tree/call.js +62 -0
- data/lib/less/js/less/lib/less/tree/color.js +189 -0
- data/lib/less/js/less/lib/less/tree/combinator.js +23 -0
- data/lib/less/js/less/lib/less/tree/comment.js +21 -0
- data/lib/less/js/less/lib/less/tree/condition.js +37 -0
- data/lib/less/js/less/lib/less/tree/debug-info.js +38 -0
- data/lib/less/js/less/lib/less/tree/detached-ruleset.js +21 -0
- data/lib/less/js/less/lib/less/tree/dimension.js +157 -0
- data/lib/less/js/less/lib/less/tree/directive.js +133 -0
- data/lib/less/js/less/lib/less/tree/element.js +60 -0
- data/lib/less/js/less/lib/less/tree/expression.js +56 -0
- data/lib/less/js/less/lib/less/tree/extend.js +56 -0
- data/lib/less/js/less/lib/less/tree/import.js +165 -0
- data/lib/less/js/less/lib/less/tree/index.js +41 -0
- data/lib/less/js/less/lib/less/tree/javascript.js +28 -0
- data/lib/less/js/less/lib/less/tree/js-eval-node.js +61 -0
- data/lib/less/js/less/lib/less/tree/keyword.js +14 -0
- data/lib/less/js/less/lib/less/tree/media.js +144 -0
- data/lib/less/js/less/lib/less/tree/mixin-call.js +182 -0
- data/lib/less/js/less/lib/less/tree/mixin-definition.js +200 -0
- data/lib/less/js/less/lib/less/tree/negative.js +20 -0
- data/lib/less/js/less/lib/less/tree/node.js +123 -0
- data/lib/less/js/less/lib/less/tree/operation.js +48 -0
- data/lib/less/js/less/lib/less/tree/paren.js +16 -0
- data/lib/less/js/less/lib/less/tree/quoted.js +55 -0
- data/lib/less/js/less/lib/less/tree/rule.js +95 -0
- data/lib/less/js/less/lib/less/tree/ruleset-call.js +13 -0
- data/lib/less/js/less/lib/less/tree/ruleset.js +709 -0
- data/lib/less/js/less/lib/less/tree/selector.js +111 -0
- data/lib/less/js/less/lib/less/tree/unicode-descriptor.js +9 -0
- data/lib/less/js/less/lib/less/tree/unit.js +120 -0
- data/lib/less/js/less/lib/less/tree/url.js +54 -0
- data/lib/less/js/less/lib/less/tree/value.js +34 -0
- data/lib/less/js/less/lib/less/tree/variable.js +53 -0
- data/lib/less/js/less/lib/less/utils.js +20 -0
- data/lib/less/js/less/lib/less/visitors/extend-visitor.js +460 -0
- data/lib/less/js/less/lib/less/visitors/import-sequencer.js +54 -0
- data/lib/less/js/less/lib/less/visitors/import-visitor.js +189 -0
- data/lib/less/js/less/lib/less/visitors/index.js +10 -0
- data/lib/less/js/less/lib/less/visitors/join-selector-visitor.js +51 -0
- data/lib/less/js/less/lib/less/visitors/set-tree-visibility-visitor.js +38 -0
- data/lib/less/js/less/lib/less/visitors/to-css-visitor.js +383 -0
- data/lib/less/js/less/lib/less/visitors/visitor.js +152 -0
- data/lib/less/js/less/lib/source-map/source-map-0.1.31.js +1933 -0
- data/lib/less/js/less/lib/source-map/source-map-footer.js +4 -0
- data/lib/less/js/less/lib/source-map/source-map-header.js +3 -0
- data/lib/less/js/less/package.json +89 -0
- data/lib/less/js/less/test/browser/common.js +206 -0
- data/lib/less/js/less/test/browser/css/global-vars/simple.css +3 -0
- data/lib/less/js/less/test/browser/css/modify-vars/simple.css +8 -0
- data/lib/less/js/less/test/browser/css/postProcessor/postProcessor.css +4 -0
- data/lib/less/js/less/test/browser/css/relative-urls/urls.css +36 -0
- data/lib/less/js/less/test/browser/css/rootpath-relative/urls.css +35 -0
- data/lib/less/js/less/test/browser/css/rootpath/urls.css +35 -0
- data/lib/less/js/less/test/browser/css/urls.css +57 -0
- data/lib/less/js/less/test/browser/jasmine-jsreporter.js +391 -0
- data/lib/less/js/less/test/browser/less/console-errors/test-error.less +3 -0
- data/lib/less/js/less/test/browser/less/console-errors/test-error.txt +2 -0
- data/lib/less/js/less/test/browser/less/errors/image-height-error.less +3 -0
- data/lib/less/js/less/test/browser/less/errors/image-height-error.txt +4 -0
- data/lib/less/js/less/test/browser/less/errors/image-size-error.less +3 -0
- data/lib/less/js/less/test/browser/less/errors/image-size-error.txt +4 -0
- data/lib/less/js/less/test/browser/less/errors/image-width-error.less +3 -0
- data/lib/less/js/less/test/browser/less/errors/image-width-error.txt +4 -0
- data/lib/less/js/less/test/browser/less/global-vars/simple.less +3 -0
- data/lib/less/js/less/test/browser/less/imports/urls.less +4 -0
- data/lib/less/js/less/test/browser/less/imports/urls2.less +4 -0
- data/lib/less/js/less/test/browser/less/modify-vars/imports/simple2.less +4 -0
- data/lib/less/js/less/test/browser/less/modify-vars/simple.less +8 -0
- data/lib/less/js/less/test/browser/less/nested-gradient-with-svg-gradient/mixin-consumer.less +5 -0
- data/lib/less/js/less/test/browser/less/nested-gradient-with-svg-gradient/svg-gradient-mixin.less +15 -0
- data/lib/less/js/less/test/browser/less/postProcessor/postProcessor.less +4 -0
- data/lib/less/js/less/test/browser/less/relative-urls/urls.less +34 -0
- data/lib/less/js/less/test/browser/less/rootpath-relative/urls.less +33 -0
- data/lib/less/js/less/test/browser/less/rootpath/urls.less +33 -0
- data/lib/less/js/less/test/browser/less/urls.less +65 -0
- data/lib/less/js/less/test/browser/runner-VisitorPlugin-options.js +3 -0
- data/lib/less/js/less/test/browser/runner-VisitorPlugin.js +3 -0
- data/lib/less/js/less/test/browser/runner-browser-options.js +51 -0
- data/lib/less/js/less/test/browser/runner-browser-spec.js +12 -0
- data/lib/less/js/less/test/browser/runner-console-errors.js +5 -0
- data/lib/less/js/less/test/browser/runner-errors-options.js +4 -0
- data/lib/less/js/less/test/browser/runner-errors-spec.js +3 -0
- data/lib/less/js/less/test/browser/runner-filemanagerPlugin-options.js +4 -0
- data/lib/less/js/less/test/browser/runner-filemanagerPlugin.js +3 -0
- data/lib/less/js/less/test/browser/runner-global-vars-options.js +7 -0
- data/lib/less/js/less/test/browser/runner-global-vars-spec.js +3 -0
- data/lib/less/js/less/test/browser/runner-legacy-options.js +5 -0
- data/lib/less/js/less/test/browser/runner-legacy-spec.js +3 -0
- data/lib/less/js/less/test/browser/runner-main-options.js +18 -0
- data/lib/less/js/less/test/browser/runner-main-spec.js +7 -0
- data/lib/less/js/less/test/browser/runner-modify-vars-options.js +5 -0
- data/lib/less/js/less/test/browser/runner-modify-vars-spec.js +33 -0
- data/lib/less/js/less/test/browser/runner-no-js-errors-options.js +4 -0
- data/lib/less/js/less/test/browser/runner-no-js-errors-spec.js +3 -0
- data/lib/less/js/less/test/browser/runner-postProcessor-options.js +5 -0
- data/lib/less/js/less/test/browser/runner-postProcessor.js +3 -0
- data/lib/less/js/less/test/browser/runner-postProcessorPlugin-options.js +3 -0
- data/lib/less/js/less/test/browser/runner-postProcessorPlugin.js +3 -0
- data/lib/less/js/less/test/browser/runner-preProcessorPlugin-options.js +3 -0
- data/lib/less/js/less/test/browser/runner-preProcessorPlugin.js +3 -0
- data/lib/less/js/less/test/browser/runner-production-options.js +3 -0
- data/lib/less/js/less/test/browser/runner-production-spec.js +5 -0
- data/lib/less/js/less/test/browser/runner-relative-urls-options.js +3 -0
- data/lib/less/js/less/test/browser/runner-relative-urls-spec.js +3 -0
- data/lib/less/js/less/test/browser/runner-rootpath-options.js +3 -0
- data/lib/less/js/less/test/browser/runner-rootpath-relative-options.js +4 -0
- data/lib/less/js/less/test/browser/runner-rootpath-relative-spec.js +3 -0
- data/lib/less/js/less/test/browser/runner-rootpath-spec.js +3 -0
- data/lib/less/js/less/test/browser/runner-strict-units-options.js +5 -0
- data/lib/less/js/less/test/browser/runner-strict-units-spec.js +3 -0
- data/lib/less/js/less/test/browser/test-runner-template.tmpl +95 -0
- data/lib/less/js/less/test/copy-bom.js +72 -0
- data/lib/less/js/less/test/css/charsets.css +1 -0
- data/lib/less/js/less/test/css/colors.css +87 -0
- data/lib/less/js/less/test/css/comments.css +83 -0
- data/lib/less/js/less/test/css/comments2.css +18 -0
- data/lib/less/js/less/test/css/compression/compression.css +3 -0
- data/lib/less/js/less/test/css/css-3.css +157 -0
- data/lib/less/js/less/test/css/css-escapes.css +24 -0
- data/lib/less/js/less/test/css/css-guards.css +37 -0
- data/lib/less/js/less/test/css/css.css +95 -0
- data/lib/less/js/less/test/css/debug/linenumbers-all.css +50 -0
- data/lib/less/js/less/test/css/debug/linenumbers-comments.css +41 -0
- data/lib/less/js/less/test/css/debug/linenumbers-mediaquery.css +41 -0
- data/lib/less/js/less/test/css/detached-rulesets.css +76 -0
- data/lib/less/js/less/test/css/directives-bubling.css +119 -0
- data/lib/less/js/less/test/css/empty.css +0 -0
- data/lib/less/js/less/test/css/extend-chaining.css +81 -0
- data/lib/less/js/less/test/css/extend-clearfix.css +19 -0
- data/lib/less/js/less/test/css/extend-exact.css +37 -0
- data/lib/less/js/less/test/css/extend-media.css +24 -0
- data/lib/less/js/less/test/css/extend-nest.css +57 -0
- data/lib/less/js/less/test/css/extend-selector.css +87 -0
- data/lib/less/js/less/test/css/extend.css +76 -0
- data/lib/less/js/less/test/css/extract-and-length.css +133 -0
- data/lib/less/js/less/test/css/filemanagerPlugin/filemanager.css +3 -0
- data/lib/less/js/less/test/css/functions.css +201 -0
- data/lib/less/js/less/test/css/globalVars/extended.css +12 -0
- data/lib/less/js/less/test/css/globalVars/simple.css +6 -0
- data/lib/less/js/less/test/css/ie-filters.css +9 -0
- data/lib/less/js/less/test/css/import-inline.css +8 -0
- data/lib/less/js/less/test/css/import-interpolation.css +13 -0
- data/lib/less/js/less/test/css/import-once.css +15 -0
- data/lib/less/js/less/test/css/import-reference-issues.css +24 -0
- data/lib/less/js/less/test/css/import-reference.css +97 -0
- data/lib/less/js/less/test/css/import.css +49 -0
- data/lib/less/js/less/test/css/include-path-string/include-path-string.css +3 -0
- data/lib/less/js/less/test/css/include-path/include-path.css +9 -0
- data/lib/less/js/less/test/css/javascript.css +28 -0
- data/lib/less/js/less/test/css/lazy-eval.css +3 -0
- data/lib/less/js/less/test/css/legacy/legacy.css +21 -0
- data/lib/less/js/less/test/css/media.css +218 -0
- data/lib/less/js/less/test/css/merge.css +34 -0
- data/lib/less/js/less/test/css/mixins-args.css +163 -0
- data/lib/less/js/less/test/css/mixins-closure.css +9 -0
- data/lib/less/js/less/test/css/mixins-guards-default-func.css +129 -0
- data/lib/less/js/less/test/css/mixins-guards.css +211 -0
- data/lib/less/js/less/test/css/mixins-important.css +57 -0
- data/lib/less/js/less/test/css/mixins-interpolated.css +43 -0
- data/lib/less/js/less/test/css/mixins-named-args.css +27 -0
- data/lib/less/js/less/test/css/mixins-nested.css +14 -0
- data/lib/less/js/less/test/css/mixins-pattern.css +51 -0
- data/lib/less/js/less/test/css/mixins.css +144 -0
- data/lib/less/js/less/test/css/modifyVars/extended.css +9 -0
- data/lib/less/js/less/test/css/no-output.css +0 -0
- data/lib/less/js/less/test/css/no-strict-math/mixins-guards.css +12 -0
- data/lib/less/js/less/test/css/no-strict-math/no-sm-operations.css +12 -0
- data/lib/less/js/less/test/css/operations.css +50 -0
- data/lib/less/js/less/test/css/parens.css +36 -0
- data/lib/less/js/less/test/css/plugin.css +44 -0
- data/lib/less/js/less/test/css/postProcessorPlugin/postProcessor.css +4 -0
- data/lib/less/js/less/test/css/preProcessorPlugin/preProcessor.css +3 -0
- data/lib/less/js/less/test/css/property-name-interp.css +21 -0
- data/lib/less/js/less/test/css/rulesets.css +33 -0
- data/lib/less/js/less/test/css/scope.css +38 -0
- data/lib/less/js/less/test/css/selectors.css +170 -0
- data/lib/less/js/less/test/css/static-urls/urls.css +46 -0
- data/lib/less/js/less/test/css/strict-units/strict-units.css +4 -0
- data/lib/less/js/less/test/css/strings.css +55 -0
- data/lib/less/js/less/test/css/url-args/urls.css +56 -0
- data/lib/less/js/less/test/css/urls.css +87 -0
- data/lib/less/js/less/test/css/variables-in-at-rules.css +18 -0
- data/lib/less/js/less/test/css/variables.css +68 -0
- data/lib/less/js/less/test/css/visitorPlugin/visitor.css +3 -0
- data/lib/less/js/less/test/css/whitespace.css +42 -0
- data/lib/less/js/less/test/data/data-uri-fail.png +0 -0
- data/lib/less/js/less/test/data/image.jpg +0 -0
- data/lib/less/js/less/test/data/image.svg +4 -0
- data/lib/less/js/less/test/data/page.html +1 -0
- data/lib/less/js/less/test/index.js +59 -0
- data/lib/less/js/less/test/less-test.js +386 -0
- data/lib/less/js/less/test/less/charsets.less +3 -0
- data/lib/less/js/less/test/less/colors.less +98 -0
- data/lib/less/js/less/test/less/comments.less +102 -0
- data/lib/less/js/less/test/less/comments2.less +31 -0
- data/lib/less/js/less/test/less/compression/compression.less +36 -0
- data/lib/less/js/less/test/less/css-3.less +162 -0
- data/lib/less/js/less/test/less/css-escapes.less +33 -0
- data/lib/less/js/less/test/less/css-guards.less +103 -0
- data/lib/less/js/less/test/less/css.less +108 -0
- data/lib/less/js/less/test/less/debug/import/test.less +25 -0
- data/lib/less/js/less/test/less/debug/linenumbers.less +33 -0
- data/lib/less/js/less/test/less/detached-rulesets.less +112 -0
- data/lib/less/js/less/test/less/directives-bubling.less +142 -0
- data/lib/less/js/less/test/less/empty.less +0 -0
- data/lib/less/js/less/test/less/errors/add-mixed-units.less +3 -0
- data/lib/less/js/less/test/less/errors/add-mixed-units.txt +4 -0
- data/lib/less/js/less/test/less/errors/add-mixed-units2.less +3 -0
- data/lib/less/js/less/test/less/errors/add-mixed-units2.txt +4 -0
- data/lib/less/js/less/test/less/errors/at-rules-undefined-var.less +4 -0
- data/lib/less/js/less/test/less/errors/at-rules-undefined-var.txt +4 -0
- data/lib/less/js/less/test/less/errors/bad-variable-declaration1.less +1 -0
- data/lib/less/js/less/test/less/errors/bad-variable-declaration1.txt +2 -0
- data/lib/less/js/less/test/less/errors/color-func-invalid-color.less +3 -0
- data/lib/less/js/less/test/less/errors/color-func-invalid-color.txt +4 -0
- data/lib/less/js/less/test/less/errors/color-invalid-hex-code.less +3 -0
- data/lib/less/js/less/test/less/errors/color-invalid-hex-code.txt +4 -0
- data/lib/less/js/less/test/less/errors/color-invalid-hex-code2.less +3 -0
- data/lib/less/js/less/test/less/errors/color-invalid-hex-code2.txt +4 -0
- data/lib/less/js/less/test/less/errors/css-guard-default-func.less +4 -0
- data/lib/less/js/less/test/less/errors/css-guard-default-func.txt +4 -0
- data/lib/less/js/less/test/less/errors/detached-ruleset-1.less +6 -0
- data/lib/less/js/less/test/less/errors/detached-ruleset-1.txt +4 -0
- data/lib/less/js/less/test/less/errors/detached-ruleset-2.less +6 -0
- data/lib/less/js/less/test/less/errors/detached-ruleset-2.txt +4 -0
- data/lib/less/js/less/test/less/errors/detached-ruleset-3.less +4 -0
- data/lib/less/js/less/test/less/errors/detached-ruleset-3.txt +4 -0
- data/lib/less/js/less/test/less/errors/detached-ruleset-5.less +4 -0
- data/lib/less/js/less/test/less/errors/detached-ruleset-5.txt +3 -0
- data/lib/less/js/less/test/less/errors/detached-ruleset-6.less +5 -0
- data/lib/less/js/less/test/less/errors/detached-ruleset-6.txt +4 -0
- data/lib/less/js/less/test/less/errors/divide-mixed-units.less +3 -0
- data/lib/less/js/less/test/less/errors/divide-mixed-units.txt +4 -0
- data/lib/less/js/less/test/less/errors/extend-no-selector.less +3 -0
- data/lib/less/js/less/test/less/errors/extend-no-selector.txt +3 -0
- data/lib/less/js/less/test/less/errors/extend-not-at-end.less +3 -0
- data/lib/less/js/less/test/less/errors/extend-not-at-end.txt +3 -0
- data/lib/less/js/less/test/less/errors/import-malformed.less +1 -0
- data/lib/less/js/less/test/less/errors/import-malformed.txt +3 -0
- data/lib/less/js/less/test/less/errors/import-missing.less +6 -0
- data/lib/less/js/less/test/less/errors/import-missing.txt +3 -0
- data/lib/less/js/less/test/less/errors/import-no-semi.less +1 -0
- data/lib/less/js/less/test/less/errors/import-no-semi.txt +2 -0
- data/lib/less/js/less/test/less/errors/import-subfolder1.less +1 -0
- data/lib/less/js/less/test/less/errors/import-subfolder1.txt +3 -0
- data/lib/less/js/less/test/less/errors/import-subfolder2.less +1 -0
- data/lib/less/js/less/test/less/errors/import-subfolder2.txt +4 -0
- data/lib/less/js/less/test/less/errors/imports/import-subfolder1.less +1 -0
- data/lib/less/js/less/test/less/errors/imports/import-subfolder2.less +1 -0
- data/lib/less/js/less/test/less/errors/imports/import-test.less +4 -0
- data/lib/less/js/less/test/less/errors/imports/subfolder/mixin-not-defined.less +1 -0
- data/lib/less/js/less/test/less/errors/imports/subfolder/parse-error-curly-bracket.less +1 -0
- data/lib/less/js/less/test/less/errors/javascript-error.less +3 -0
- data/lib/less/js/less/test/less/errors/javascript-error.txt +4 -0
- data/lib/less/js/less/test/less/errors/javascript-undefined-var.less +3 -0
- data/lib/less/js/less/test/less/errors/javascript-undefined-var.txt +4 -0
- data/lib/less/js/less/test/less/errors/mixed-mixin-definition-args-1.less +6 -0
- data/lib/less/js/less/test/less/errors/mixed-mixin-definition-args-1.txt +4 -0
- data/lib/less/js/less/test/less/errors/mixed-mixin-definition-args-2.less +6 -0
- data/lib/less/js/less/test/less/errors/mixed-mixin-definition-args-2.txt +4 -0
- data/lib/less/js/less/test/less/errors/mixin-not-defined.less +11 -0
- data/lib/less/js/less/test/less/errors/mixin-not-defined.txt +3 -0
- data/lib/less/js/less/test/less/errors/mixin-not-matched.less +6 -0
- data/lib/less/js/less/test/less/errors/mixin-not-matched.txt +3 -0
- data/lib/less/js/less/test/less/errors/mixin-not-matched2.less +6 -0
- data/lib/less/js/less/test/less/errors/mixin-not-matched2.txt +3 -0
- data/lib/less/js/less/test/less/errors/mixin-not-visible-in-scope-1.less +9 -0
- data/lib/less/js/less/test/less/errors/mixin-not-visible-in-scope-1.txt +4 -0
- data/lib/less/js/less/test/less/errors/mixins-guards-default-func-1.less +9 -0
- data/lib/less/js/less/test/less/errors/mixins-guards-default-func-1.txt +4 -0
- data/lib/less/js/less/test/less/errors/mixins-guards-default-func-2.less +9 -0
- data/lib/less/js/less/test/less/errors/mixins-guards-default-func-2.txt +4 -0
- data/lib/less/js/less/test/less/errors/mixins-guards-default-func-3.less +9 -0
- data/lib/less/js/less/test/less/errors/mixins-guards-default-func-3.txt +4 -0
- data/lib/less/js/less/test/less/errors/multiple-guards-on-css-selectors.less +4 -0
- data/lib/less/js/less/test/less/errors/multiple-guards-on-css-selectors.txt +4 -0
- data/lib/less/js/less/test/less/errors/multiple-guards-on-css-selectors2.less +4 -0
- data/lib/less/js/less/test/less/errors/multiple-guards-on-css-selectors2.txt +4 -0
- data/lib/less/js/less/test/less/errors/multiply-mixed-units.less +7 -0
- data/lib/less/js/less/test/less/errors/multiply-mixed-units.txt +4 -0
- data/lib/less/js/less/test/less/errors/parens-error-1.less +3 -0
- data/lib/less/js/less/test/less/errors/parens-error-1.txt +4 -0
- data/lib/less/js/less/test/less/errors/parens-error-2.less +3 -0
- data/lib/less/js/less/test/less/errors/parens-error-2.txt +4 -0
- data/lib/less/js/less/test/less/errors/parens-error-3.less +3 -0
- data/lib/less/js/less/test/less/errors/parens-error-3.txt +4 -0
- data/lib/less/js/less/test/less/errors/parse-error-curly-bracket.less +4 -0
- data/lib/less/js/less/test/less/errors/parse-error-curly-bracket.txt +4 -0
- data/lib/less/js/less/test/less/errors/parse-error-media-no-block-1.less +5 -0
- data/lib/less/js/less/test/less/errors/parse-error-media-no-block-1.txt +3 -0
- data/lib/less/js/less/test/less/errors/parse-error-media-no-block-2.less +1 -0
- data/lib/less/js/less/test/less/errors/parse-error-media-no-block-2.txt +2 -0
- data/lib/less/js/less/test/less/errors/parse-error-media-no-block-3.less +4 -0
- data/lib/less/js/less/test/less/errors/parse-error-media-no-block-3.txt +3 -0
- data/lib/less/js/less/test/less/errors/parse-error-missing-bracket.less +2 -0
- data/lib/less/js/less/test/less/errors/parse-error-missing-bracket.txt +3 -0
- data/lib/less/js/less/test/less/errors/parse-error-missing-parens.less +5 -0
- data/lib/less/js/less/test/less/errors/parse-error-missing-parens.txt +3 -0
- data/lib/less/js/less/test/less/errors/parse-error-with-import.less +13 -0
- data/lib/less/js/less/test/less/errors/parse-error-with-import.txt +4 -0
- data/lib/less/js/less/test/less/errors/percentage-missing-space.less +3 -0
- data/lib/less/js/less/test/less/errors/percentage-missing-space.txt +4 -0
- data/lib/less/js/less/test/less/errors/percentage-non-number-argument.less +3 -0
- data/lib/less/js/less/test/less/errors/percentage-non-number-argument.txt +4 -0
- data/lib/less/js/less/test/less/errors/property-asterisk-only-name.less +3 -0
- data/lib/less/js/less/test/less/errors/property-asterisk-only-name.txt +4 -0
- data/lib/less/js/less/test/less/errors/property-ie5-hack.less +3 -0
- data/lib/less/js/less/test/less/errors/property-ie5-hack.txt +3 -0
- data/lib/less/js/less/test/less/errors/property-in-root.less +4 -0
- data/lib/less/js/less/test/less/errors/property-in-root.txt +4 -0
- data/lib/less/js/less/test/less/errors/property-in-root2.less +1 -0
- data/lib/less/js/less/test/less/errors/property-in-root2.txt +4 -0
- data/lib/less/js/less/test/less/errors/property-in-root3.less +4 -0
- data/lib/less/js/less/test/less/errors/property-in-root3.txt +3 -0
- data/lib/less/js/less/test/less/errors/property-interp-not-defined.less +1 -0
- data/lib/less/js/less/test/less/errors/property-interp-not-defined.txt +2 -0
- data/lib/less/js/less/test/less/errors/recursive-variable.less +1 -0
- data/lib/less/js/less/test/less/errors/recursive-variable.txt +2 -0
- data/lib/less/js/less/test/less/errors/single-character.less +1 -0
- data/lib/less/js/less/test/less/errors/single-character.txt +2 -0
- data/lib/less/js/less/test/less/errors/svg-gradient1.less +3 -0
- data/lib/less/js/less/test/less/errors/svg-gradient1.txt +4 -0
- data/lib/less/js/less/test/less/errors/svg-gradient2.less +3 -0
- data/lib/less/js/less/test/less/errors/svg-gradient2.txt +4 -0
- data/lib/less/js/less/test/less/errors/svg-gradient3.less +3 -0
- data/lib/less/js/less/test/less/errors/svg-gradient3.txt +4 -0
- data/lib/less/js/less/test/less/errors/svg-gradient4.less +4 -0
- data/lib/less/js/less/test/less/errors/svg-gradient4.txt +4 -0
- data/lib/less/js/less/test/less/errors/svg-gradient5.less +4 -0
- data/lib/less/js/less/test/less/errors/svg-gradient5.txt +4 -0
- data/lib/less/js/less/test/less/errors/svg-gradient6.less +4 -0
- data/lib/less/js/less/test/less/errors/svg-gradient6.txt +4 -0
- data/lib/less/js/less/test/less/errors/unit-function.less +3 -0
- data/lib/less/js/less/test/less/errors/unit-function.txt +4 -0
- data/lib/less/js/less/test/less/extend-chaining.less +91 -0
- data/lib/less/js/less/test/less/extend-clearfix.less +19 -0
- data/lib/less/js/less/test/less/extend-exact.less +46 -0
- data/lib/less/js/less/test/less/extend-media.less +24 -0
- data/lib/less/js/less/test/less/extend-nest.less +65 -0
- data/lib/less/js/less/test/less/extend-selector.less +110 -0
- data/lib/less/js/less/test/less/extend.less +81 -0
- data/lib/less/js/less/test/less/extract-and-length.less +133 -0
- data/lib/less/js/less/test/less/filemanagerPlugin/colors.test +1 -0
- data/lib/less/js/less/test/less/filemanagerPlugin/filemanager.less +4 -0
- data/lib/less/js/less/test/less/functions.less +232 -0
- data/lib/less/js/less/test/less/globalVars/extended.json +5 -0
- data/lib/less/js/less/test/less/globalVars/extended.less +10 -0
- data/lib/less/js/less/test/less/globalVars/simple.json +3 -0
- data/lib/less/js/less/test/less/globalVars/simple.less +3 -0
- data/lib/less/js/less/test/less/ie-filters.less +15 -0
- data/lib/less/js/less/test/less/import-inline.less +3 -0
- data/lib/less/js/less/test/less/import-interpolation.less +8 -0
- data/lib/less/js/less/test/less/import-once.less +6 -0
- data/lib/less/js/less/test/less/import-reference-issues.less +50 -0
- data/lib/less/js/less/test/less/import-reference-issues/appender-reference-1968.less +6 -0
- data/lib/less/js/less/test/less/import-reference-issues/global-scope-import.less +13 -0
- data/lib/less/js/less/test/less/import-reference-issues/global-scope-nested.less +3 -0
- data/lib/less/js/less/test/less/import-reference-issues/mixin-1968.less +8 -0
- data/lib/less/js/less/test/less/import-reference-issues/multiple-import-nested.less +12 -0
- data/lib/less/js/less/test/less/import-reference-issues/multiple-import.less +10 -0
- data/lib/less/js/less/test/less/import-reference-issues/simple-mixin.css +3 -0
- data/lib/less/js/less/test/less/import-reference-issues/simple-ruleset-2162.less +3 -0
- data/lib/less/js/less/test/less/import-reference.less +26 -0
- data/lib/less/js/less/test/less/import.less +31 -0
- data/lib/less/js/less/test/less/import/css-import.less +1 -0
- data/lib/less/js/less/test/less/import/deeper/deeper-2/url-import-2.less +3 -0
- data/lib/less/js/less/test/less/import/deeper/deeper-2/url-import.less +1 -0
- data/lib/less/js/less/test/less/import/deeper/import-once-test-a.less +1 -0
- data/lib/less/js/less/test/less/import/deeper/url-import.less +1 -0
- data/lib/less/js/less/test/less/import/import-and-relative-paths-test.less +17 -0
- data/lib/less/js/less/test/less/import/import-charset-test.less +1 -0
- data/lib/less/js/less/test/less/import/import-inline-invalid-css.less +1 -0
- data/lib/less/js/less/test/less/import/import-interpolation.less +2 -0
- data/lib/less/js/less/test/less/import/import-interpolation2.less +5 -0
- data/lib/less/js/less/test/less/import/import-once-test-c.less +6 -0
- data/lib/less/js/less/test/less/import/import-reference.less +98 -0
- data/lib/less/js/less/test/less/import/import-test-a.less +5 -0
- data/lib/less/js/less/test/less/import/import-test-b.less +8 -0
- data/lib/less/js/less/test/less/import/import-test-c.less +6 -0
- data/lib/less/js/less/test/less/import/import-test-d.css +1 -0
- data/lib/less/js/less/test/less/import/import-test-e.less +2 -0
- data/lib/less/js/less/test/less/import/import-test-f.less +5 -0
- data/lib/less/js/less/test/less/import/imports/font.less +8 -0
- data/lib/less/js/less/test/less/import/imports/logo.less +6 -0
- data/lib/less/js/less/test/less/import/interpolation-vars.less +6 -0
- data/lib/less/js/less/test/less/import/invalid-css.less +1 -0
- data/lib/less/js/less/test/less/import/urls.less +1 -0
- data/lib/less/js/less/test/less/include-path-string/include-path-string.less +3 -0
- data/lib/less/js/less/test/less/include-path/include-path.less +8 -0
- data/lib/less/js/less/test/less/javascript.less +38 -0
- data/lib/less/js/less/test/less/lazy-eval.less +6 -0
- data/lib/less/js/less/test/less/legacy/legacy.less +21 -0
- data/lib/less/js/less/test/less/media.less +234 -0
- data/lib/less/js/less/test/less/merge.less +78 -0
- data/lib/less/js/less/test/less/mixins-args.less +263 -0
- data/lib/less/js/less/test/less/mixins-closure.less +26 -0
- data/lib/less/js/less/test/less/mixins-guards-default-func.less +195 -0
- data/lib/less/js/less/test/less/mixins-guards.less +358 -0
- data/lib/less/js/less/test/less/mixins-important.less +53 -0
- data/lib/less/js/less/test/less/mixins-interpolated.less +75 -0
- data/lib/less/js/less/test/less/mixins-named-args.less +36 -0
- data/lib/less/js/less/test/less/mixins-nested.less +22 -0
- data/lib/less/js/less/test/less/mixins-pattern.less +102 -0
- data/lib/less/js/less/test/less/mixins.less +145 -0
- data/lib/less/js/less/test/less/modifyVars/extended.json +5 -0
- data/lib/less/js/less/test/less/modifyVars/extended.less +11 -0
- data/lib/less/js/less/test/less/nested-gradient-with-svg-gradient/mixin-consumer.less +5 -0
- data/lib/less/js/less/test/less/nested-gradient-with-svg-gradient/svg-gradient-mixin.less +15 -0
- data/lib/less/js/less/test/less/no-js-errors/no-js-errors.less +3 -0
- data/lib/less/js/less/test/less/no-js-errors/no-js-errors.txt +4 -0
- data/lib/less/js/less/test/less/no-output.less +2 -0
- data/lib/less/js/less/test/less/no-strict-math/mixins-guards.less +25 -0
- data/lib/less/js/less/test/less/no-strict-math/no-sm-operations.less +10 -0
- data/lib/less/js/less/test/less/operations.less +63 -0
- data/lib/less/js/less/test/less/parens.less +45 -0
- data/lib/less/js/less/test/less/plugin.less +85 -0
- data/lib/less/js/less/test/less/plugin/plugin-global.js +9 -0
- data/lib/less/js/less/test/less/plugin/plugin-local.js +8 -0
- data/lib/less/js/less/test/less/plugin/plugin-transitive.js +5 -0
- data/lib/less/js/less/test/less/plugin/plugin-transitive.less +5 -0
- data/lib/less/js/less/test/less/postProcessorPlugin/postProcessor.less +4 -0
- data/lib/less/js/less/test/less/preProcessorPlugin/preProcessor.less +3 -0
- data/lib/less/js/less/test/less/property-name-interp.less +56 -0
- data/lib/less/js/less/test/less/rulesets.less +30 -0
- data/lib/less/js/less/test/less/scope.less +104 -0
- data/lib/less/js/less/test/less/selectors.less +184 -0
- data/lib/less/js/less/test/less/sourcemaps-empty/empty.less +0 -0
- data/lib/less/js/less/test/less/sourcemaps-empty/var-defs.less +1 -0
- data/lib/less/js/less/test/less/sourcemaps/basic.json +3 -0
- data/lib/less/js/less/test/less/sourcemaps/basic.less +27 -0
- data/lib/less/js/less/test/less/sourcemaps/imported.css +7 -0
- data/lib/less/js/less/test/less/static-urls/urls.less +33 -0
- data/lib/less/js/less/test/less/strict-units/strict-units.less +4 -0
- data/lib/less/js/less/test/less/strings.less +73 -0
- data/lib/less/js/less/test/less/url-args/urls.less +63 -0
- data/lib/less/js/less/test/less/urls.less +94 -0
- data/lib/less/js/less/test/less/variables-in-at-rules.less +20 -0
- data/lib/less/js/less/test/less/variables.less +119 -0
- data/lib/less/js/less/test/less/visitorPlugin/visitor.less +4 -0
- data/lib/less/js/less/test/less/whitespace.less +44 -0
- data/lib/less/js/less/test/modify-vars.js +19 -0
- data/lib/less/js/less/test/plugins/filemanager/index.js +19 -0
- data/lib/less/js/less/test/plugins/postprocess/index.js +14 -0
- data/lib/less/js/less/test/plugins/preprocess/index.js +19 -0
- data/lib/less/js/less/test/plugins/visitor/index.js +24 -0
- data/lib/less/js/less/test/rhino/test-header.js +15 -0
- data/lib/less/js/less/test/sourcemaps/basic.json +1 -0
- data/lib/less/js/less/test/sourcemaps/index.html +17 -0
- data/lib/less/js/node-mime/.gitignore +2 -0
- data/lib/less/js/node-mime/.npmignore +0 -0
- data/lib/less/js/node-mime/LICENSE +19 -0
- data/lib/less/js/node-mime/README.md +90 -0
- data/lib/less/js/node-mime/build/build.js +11 -0
- data/lib/less/js/node-mime/build/test.js +57 -0
- data/lib/less/js/node-mime/cli.js +8 -0
- data/lib/less/js/node-mime/mime.js +108 -0
- data/lib/less/js/node-mime/package.json +41 -0
- data/lib/less/js/node-mime/types.json +1 -0
- data/lib/less/loader.rb +13 -0
- data/lib/less/parser.rb +62 -0
- data/lib/less/runner.js +20 -0
- data/lib/less/version.rb +3 -0
- data/script/bootstrap +6 -0
- data/script/cibuild +7 -0
- data/spec/less/parser_spec.rb +170 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/support/custom_functions/custom_functions.js +7 -0
- data/spec/support/custom_functions/custom_functions.less +3 -0
- data/spec/support/faulty/faulty.less +3 -0
- data/spec/support/less.js.tests-custom-functions.js +20 -0
- data/spec/support/one/one.less +1 -0
- data/spec/support/two/two.less +1 -0
- metadata +733 -0
@@ -0,0 +1,48 @@
|
|
1
|
+
var Node = require("./node"),
|
2
|
+
Color = require("./color"),
|
3
|
+
Dimension = require("./dimension");
|
4
|
+
|
5
|
+
var Operation = function (op, operands, isSpaced) {
|
6
|
+
this.op = op.trim();
|
7
|
+
this.operands = operands;
|
8
|
+
this.isSpaced = isSpaced;
|
9
|
+
};
|
10
|
+
Operation.prototype = new Node();
|
11
|
+
Operation.prototype.type = "Operation";
|
12
|
+
Operation.prototype.accept = function (visitor) {
|
13
|
+
this.operands = visitor.visit(this.operands);
|
14
|
+
};
|
15
|
+
Operation.prototype.eval = function (context) {
|
16
|
+
var a = this.operands[0].eval(context),
|
17
|
+
b = this.operands[1].eval(context);
|
18
|
+
|
19
|
+
if (context.isMathOn()) {
|
20
|
+
if (a instanceof Dimension && b instanceof Color) {
|
21
|
+
a = a.toColor();
|
22
|
+
}
|
23
|
+
if (b instanceof Dimension && a instanceof Color) {
|
24
|
+
b = b.toColor();
|
25
|
+
}
|
26
|
+
if (!a.operate) {
|
27
|
+
throw { type: "Operation",
|
28
|
+
message: "Operation on an invalid type" };
|
29
|
+
}
|
30
|
+
|
31
|
+
return a.operate(context, this.op, b);
|
32
|
+
} else {
|
33
|
+
return new Operation(this.op, [a, b], this.isSpaced);
|
34
|
+
}
|
35
|
+
};
|
36
|
+
Operation.prototype.genCSS = function (context, output) {
|
37
|
+
this.operands[0].genCSS(context, output);
|
38
|
+
if (this.isSpaced) {
|
39
|
+
output.add(" ");
|
40
|
+
}
|
41
|
+
output.add(this.op);
|
42
|
+
if (this.isSpaced) {
|
43
|
+
output.add(" ");
|
44
|
+
}
|
45
|
+
this.operands[1].genCSS(context, output);
|
46
|
+
};
|
47
|
+
|
48
|
+
module.exports = Operation;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
var Node = require("./node");
|
2
|
+
|
3
|
+
var Paren = function (node) {
|
4
|
+
this.value = node;
|
5
|
+
};
|
6
|
+
Paren.prototype = new Node();
|
7
|
+
Paren.prototype.type = "Paren";
|
8
|
+
Paren.prototype.genCSS = function (context, output) {
|
9
|
+
output.add('(');
|
10
|
+
this.value.genCSS(context, output);
|
11
|
+
output.add(')');
|
12
|
+
};
|
13
|
+
Paren.prototype.eval = function (context) {
|
14
|
+
return new Paren(this.value.eval(context));
|
15
|
+
};
|
16
|
+
module.exports = Paren;
|
@@ -0,0 +1,55 @@
|
|
1
|
+
var Node = require("./node"),
|
2
|
+
JsEvalNode = require("./js-eval-node"),
|
3
|
+
Variable = require("./variable");
|
4
|
+
|
5
|
+
var Quoted = function (str, content, escaped, index, currentFileInfo) {
|
6
|
+
this.escaped = (escaped == null) ? true : escaped;
|
7
|
+
this.value = content || '';
|
8
|
+
this.quote = str.charAt(0);
|
9
|
+
this.index = index;
|
10
|
+
this.currentFileInfo = currentFileInfo;
|
11
|
+
};
|
12
|
+
Quoted.prototype = new JsEvalNode();
|
13
|
+
Quoted.prototype.type = "Quoted";
|
14
|
+
Quoted.prototype.genCSS = function (context, output) {
|
15
|
+
if (!this.escaped) {
|
16
|
+
output.add(this.quote, this.currentFileInfo, this.index);
|
17
|
+
}
|
18
|
+
output.add(this.value);
|
19
|
+
if (!this.escaped) {
|
20
|
+
output.add(this.quote);
|
21
|
+
}
|
22
|
+
};
|
23
|
+
Quoted.prototype.containsVariables = function() {
|
24
|
+
return this.value.match(/(`([^`]+)`)|@\{([\w-]+)\}/);
|
25
|
+
};
|
26
|
+
Quoted.prototype.eval = function (context) {
|
27
|
+
var that = this, value = this.value;
|
28
|
+
var javascriptReplacement = function (_, exp) {
|
29
|
+
return String(that.evaluateJavaScript(exp, context));
|
30
|
+
};
|
31
|
+
var interpolationReplacement = function (_, name) {
|
32
|
+
var v = new Variable('@' + name, that.index, that.currentFileInfo).eval(context, true);
|
33
|
+
return (v instanceof Quoted) ? v.value : v.toCSS();
|
34
|
+
};
|
35
|
+
function iterativeReplace(value, regexp, replacementFnc) {
|
36
|
+
var evaluatedValue = value;
|
37
|
+
do {
|
38
|
+
value = evaluatedValue;
|
39
|
+
evaluatedValue = value.replace(regexp, replacementFnc);
|
40
|
+
} while (value !== evaluatedValue);
|
41
|
+
return evaluatedValue;
|
42
|
+
}
|
43
|
+
value = iterativeReplace(value, /`([^`]+)`/g, javascriptReplacement);
|
44
|
+
value = iterativeReplace(value, /@\{([\w-]+)\}/g, interpolationReplacement);
|
45
|
+
return new Quoted(this.quote + value + this.quote, value, this.escaped, this.index, this.currentFileInfo);
|
46
|
+
};
|
47
|
+
Quoted.prototype.compare = function (other) {
|
48
|
+
// when comparing quoted strings allow the quote to differ
|
49
|
+
if (other.type === "Quoted" && !this.escaped && !other.escaped) {
|
50
|
+
return Node.numericCompare(this.value, other.value);
|
51
|
+
} else {
|
52
|
+
return other.toCSS && this.toCSS() === other.toCSS() ? 0 : undefined;
|
53
|
+
}
|
54
|
+
};
|
55
|
+
module.exports = Quoted;
|
@@ -0,0 +1,95 @@
|
|
1
|
+
var Node = require("./node"),
|
2
|
+
Value = require("./value"),
|
3
|
+
Keyword = require("./keyword");
|
4
|
+
|
5
|
+
var Rule = function (name, value, important, merge, index, currentFileInfo, inline, variable) {
|
6
|
+
this.name = name;
|
7
|
+
this.value = (value instanceof Node) ? value : new Value([value]); //value instanceof tree.Value || value instanceof tree.Ruleset ??
|
8
|
+
this.important = important ? ' ' + important.trim() : '';
|
9
|
+
this.merge = merge;
|
10
|
+
this.index = index;
|
11
|
+
this.currentFileInfo = currentFileInfo;
|
12
|
+
this.inline = inline || false;
|
13
|
+
this.variable = (variable !== undefined) ? variable
|
14
|
+
: (name.charAt && (name.charAt(0) === '@'));
|
15
|
+
};
|
16
|
+
|
17
|
+
function evalName(context, name) {
|
18
|
+
var value = "", i, n = name.length,
|
19
|
+
output = {add: function (s) {value += s;}};
|
20
|
+
for (i = 0; i < n; i++) {
|
21
|
+
name[i].eval(context).genCSS(context, output);
|
22
|
+
}
|
23
|
+
return value;
|
24
|
+
}
|
25
|
+
|
26
|
+
Rule.prototype = new Node();
|
27
|
+
Rule.prototype.type = "Rule";
|
28
|
+
Rule.prototype.genCSS = function (context, output) {
|
29
|
+
output.add(this.name + (context.compress ? ':' : ': '), this.currentFileInfo, this.index);
|
30
|
+
try {
|
31
|
+
this.value.genCSS(context, output);
|
32
|
+
}
|
33
|
+
catch(e) {
|
34
|
+
e.index = this.index;
|
35
|
+
e.filename = this.currentFileInfo.filename;
|
36
|
+
throw e;
|
37
|
+
}
|
38
|
+
output.add(this.important + ((this.inline || (context.lastRule && context.compress)) ? "" : ";"), this.currentFileInfo, this.index);
|
39
|
+
};
|
40
|
+
Rule.prototype.eval = function (context) {
|
41
|
+
var strictMathBypass = false, name = this.name, evaldValue, variable = this.variable;
|
42
|
+
if (typeof name !== "string") {
|
43
|
+
// expand 'primitive' name directly to get
|
44
|
+
// things faster (~10% for benchmark.less):
|
45
|
+
name = (name.length === 1) && (name[0] instanceof Keyword) ?
|
46
|
+
name[0].value : evalName(context, name);
|
47
|
+
variable = false; // never treat expanded interpolation as new variable name
|
48
|
+
}
|
49
|
+
if (name === "font" && !context.strictMath) {
|
50
|
+
strictMathBypass = true;
|
51
|
+
context.strictMath = true;
|
52
|
+
}
|
53
|
+
try {
|
54
|
+
context.importantScope.push({});
|
55
|
+
evaldValue = this.value.eval(context);
|
56
|
+
|
57
|
+
if (!this.variable && evaldValue.type === "DetachedRuleset") {
|
58
|
+
throw { message: "Rulesets cannot be evaluated on a property.",
|
59
|
+
index: this.index, filename: this.currentFileInfo.filename };
|
60
|
+
}
|
61
|
+
var important = this.important,
|
62
|
+
importantResult = context.importantScope.pop();
|
63
|
+
if (!important && importantResult.important) {
|
64
|
+
important = importantResult.important;
|
65
|
+
}
|
66
|
+
|
67
|
+
return new Rule(name,
|
68
|
+
evaldValue,
|
69
|
+
important,
|
70
|
+
this.merge,
|
71
|
+
this.index, this.currentFileInfo, this.inline,
|
72
|
+
variable);
|
73
|
+
}
|
74
|
+
catch(e) {
|
75
|
+
if (typeof e.index !== 'number') {
|
76
|
+
e.index = this.index;
|
77
|
+
e.filename = this.currentFileInfo.filename;
|
78
|
+
}
|
79
|
+
throw e;
|
80
|
+
}
|
81
|
+
finally {
|
82
|
+
if (strictMathBypass) {
|
83
|
+
context.strictMath = false;
|
84
|
+
}
|
85
|
+
}
|
86
|
+
};
|
87
|
+
Rule.prototype.makeImportant = function () {
|
88
|
+
return new Rule(this.name,
|
89
|
+
this.value,
|
90
|
+
"!important",
|
91
|
+
this.merge,
|
92
|
+
this.index, this.currentFileInfo, this.inline);
|
93
|
+
};
|
94
|
+
|
95
|
+
module.exports = Rule;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
var Node = require("./node"),
|
2
|
+
Variable = require("./variable");
|
3
|
+
|
4
|
+
var RulesetCall = function (variable) {
|
5
|
+
this.variable = variable;
|
6
|
+
};
|
7
|
+
RulesetCall.prototype = new Node();
|
8
|
+
RulesetCall.prototype.type = "RulesetCall";
|
9
|
+
RulesetCall.prototype.eval = function (context) {
|
10
|
+
var detachedRuleset = new Variable(this.variable).eval(context);
|
11
|
+
return detachedRuleset.callEval(context);
|
12
|
+
};
|
13
|
+
module.exports = RulesetCall;
|
@@ -0,0 +1,709 @@
|
|
1
|
+
var Node = require("./node"),
|
2
|
+
Rule = require("./rule"),
|
3
|
+
Selector = require("./selector"),
|
4
|
+
Element = require("./element"),
|
5
|
+
Paren = require("./paren"),
|
6
|
+
contexts = require("../contexts"),
|
7
|
+
globalFunctionRegistry = require("../functions/function-registry"),
|
8
|
+
defaultFunc = require("../functions/default"),
|
9
|
+
getDebugInfo = require("./debug-info");
|
10
|
+
|
11
|
+
var Ruleset = function (selectors, rules, strictImports, visibilityInfo) {
|
12
|
+
this.selectors = selectors;
|
13
|
+
this.rules = rules;
|
14
|
+
this._lookups = {};
|
15
|
+
this.strictImports = strictImports;
|
16
|
+
this.copyVisibilityInfo(visibilityInfo);
|
17
|
+
};
|
18
|
+
Ruleset.prototype = new Node();
|
19
|
+
Ruleset.prototype.type = "Ruleset";
|
20
|
+
Ruleset.prototype.isRuleset = true;
|
21
|
+
Ruleset.prototype.isRulesetLike = true;
|
22
|
+
Ruleset.prototype.accept = function (visitor) {
|
23
|
+
if (this.paths) {
|
24
|
+
this.paths = visitor.visitArray(this.paths, true);
|
25
|
+
} else if (this.selectors) {
|
26
|
+
this.selectors = visitor.visitArray(this.selectors);
|
27
|
+
}
|
28
|
+
if (this.rules && this.rules.length) {
|
29
|
+
this.rules = visitor.visitArray(this.rules);
|
30
|
+
}
|
31
|
+
};
|
32
|
+
Ruleset.prototype.eval = function (context) {
|
33
|
+
var thisSelectors = this.selectors, selectors,
|
34
|
+
selCnt, selector, i, hasOnePassingSelector = false;
|
35
|
+
|
36
|
+
if (thisSelectors && (selCnt = thisSelectors.length)) {
|
37
|
+
selectors = [];
|
38
|
+
defaultFunc.error({
|
39
|
+
type: "Syntax",
|
40
|
+
message: "it is currently only allowed in parametric mixin guards,"
|
41
|
+
});
|
42
|
+
for (i = 0; i < selCnt; i++) {
|
43
|
+
selector = thisSelectors[i].eval(context);
|
44
|
+
selectors.push(selector);
|
45
|
+
if (selector.evaldCondition) {
|
46
|
+
hasOnePassingSelector = true;
|
47
|
+
}
|
48
|
+
}
|
49
|
+
defaultFunc.reset();
|
50
|
+
} else {
|
51
|
+
hasOnePassingSelector = true;
|
52
|
+
}
|
53
|
+
|
54
|
+
var rules = this.rules ? this.rules.slice(0) : null,
|
55
|
+
ruleset = new Ruleset(selectors, rules, this.strictImports, this.visibilityInfo()),
|
56
|
+
rule, subRule;
|
57
|
+
|
58
|
+
ruleset.originalRuleset = this;
|
59
|
+
ruleset.root = this.root;
|
60
|
+
ruleset.firstRoot = this.firstRoot;
|
61
|
+
ruleset.allowImports = this.allowImports;
|
62
|
+
|
63
|
+
if (this.debugInfo) {
|
64
|
+
ruleset.debugInfo = this.debugInfo;
|
65
|
+
}
|
66
|
+
|
67
|
+
if (!hasOnePassingSelector) {
|
68
|
+
rules.length = 0;
|
69
|
+
}
|
70
|
+
|
71
|
+
// inherit a function registry from the frames stack when possible;
|
72
|
+
// otherwise from the global registry
|
73
|
+
ruleset.functionRegistry = (function (frames) {
|
74
|
+
var i = 0,
|
75
|
+
n = frames.length,
|
76
|
+
found;
|
77
|
+
for ( ; i !== n ; ++i ) {
|
78
|
+
found = frames[ i ].functionRegistry;
|
79
|
+
if ( found ) { return found; }
|
80
|
+
}
|
81
|
+
return globalFunctionRegistry;
|
82
|
+
}(context.frames)).inherit();
|
83
|
+
|
84
|
+
// push the current ruleset to the frames stack
|
85
|
+
var ctxFrames = context.frames;
|
86
|
+
ctxFrames.unshift(ruleset);
|
87
|
+
|
88
|
+
// currrent selectors
|
89
|
+
var ctxSelectors = context.selectors;
|
90
|
+
if (!ctxSelectors) {
|
91
|
+
context.selectors = ctxSelectors = [];
|
92
|
+
}
|
93
|
+
ctxSelectors.unshift(this.selectors);
|
94
|
+
|
95
|
+
// Evaluate imports
|
96
|
+
if (ruleset.root || ruleset.allowImports || !ruleset.strictImports) {
|
97
|
+
ruleset.evalImports(context);
|
98
|
+
}
|
99
|
+
|
100
|
+
// Store the frames around mixin definitions,
|
101
|
+
// so they can be evaluated like closures when the time comes.
|
102
|
+
var rsRules = ruleset.rules, rsRuleCnt = rsRules ? rsRules.length : 0;
|
103
|
+
for (i = 0; i < rsRuleCnt; i++) {
|
104
|
+
if (rsRules[i].evalFirst) {
|
105
|
+
rsRules[i] = rsRules[i].eval(context);
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
var mediaBlockCount = (context.mediaBlocks && context.mediaBlocks.length) || 0;
|
110
|
+
|
111
|
+
// Evaluate mixin calls.
|
112
|
+
for (i = 0; i < rsRuleCnt; i++) {
|
113
|
+
if (rsRules[i].type === "MixinCall") {
|
114
|
+
/*jshint loopfunc:true */
|
115
|
+
rules = rsRules[i].eval(context).filter(function(r) {
|
116
|
+
if ((r instanceof Rule) && r.variable) {
|
117
|
+
// do not pollute the scope if the variable is
|
118
|
+
// already there. consider returning false here
|
119
|
+
// but we need a way to "return" variable from mixins
|
120
|
+
return !(ruleset.variable(r.name));
|
121
|
+
}
|
122
|
+
return true;
|
123
|
+
});
|
124
|
+
rsRules.splice.apply(rsRules, [i, 1].concat(rules));
|
125
|
+
rsRuleCnt += rules.length - 1;
|
126
|
+
i += rules.length - 1;
|
127
|
+
ruleset.resetCache();
|
128
|
+
} else if (rsRules[i].type === "RulesetCall") {
|
129
|
+
/*jshint loopfunc:true */
|
130
|
+
rules = rsRules[i].eval(context).rules.filter(function(r) {
|
131
|
+
if ((r instanceof Rule) && r.variable) {
|
132
|
+
// do not pollute the scope at all
|
133
|
+
return false;
|
134
|
+
}
|
135
|
+
return true;
|
136
|
+
});
|
137
|
+
rsRules.splice.apply(rsRules, [i, 1].concat(rules));
|
138
|
+
rsRuleCnt += rules.length - 1;
|
139
|
+
i += rules.length - 1;
|
140
|
+
ruleset.resetCache();
|
141
|
+
}
|
142
|
+
}
|
143
|
+
|
144
|
+
// Evaluate everything else
|
145
|
+
for (i = 0; i < rsRules.length; i++) {
|
146
|
+
rule = rsRules[i];
|
147
|
+
if (!rule.evalFirst) {
|
148
|
+
rsRules[i] = rule = rule.eval ? rule.eval(context) : rule;
|
149
|
+
}
|
150
|
+
}
|
151
|
+
|
152
|
+
// Evaluate everything else
|
153
|
+
for (i = 0; i < rsRules.length; i++) {
|
154
|
+
rule = rsRules[i];
|
155
|
+
// for rulesets, check if it is a css guard and can be removed
|
156
|
+
if (rule instanceof Ruleset && rule.selectors && rule.selectors.length === 1) {
|
157
|
+
// check if it can be folded in (e.g. & where)
|
158
|
+
if (rule.selectors[0].isJustParentSelector()) {
|
159
|
+
rsRules.splice(i--, 1);
|
160
|
+
|
161
|
+
for (var j = 0; j < rule.rules.length; j++) {
|
162
|
+
subRule = rule.rules[j];
|
163
|
+
subRule.copyVisibilityInfo(rule.visibilityInfo());
|
164
|
+
if (!(subRule instanceof Rule) || !subRule.variable) {
|
165
|
+
rsRules.splice(++i, 0, subRule);
|
166
|
+
}
|
167
|
+
}
|
168
|
+
}
|
169
|
+
}
|
170
|
+
}
|
171
|
+
|
172
|
+
// Pop the stack
|
173
|
+
ctxFrames.shift();
|
174
|
+
ctxSelectors.shift();
|
175
|
+
|
176
|
+
if (context.mediaBlocks) {
|
177
|
+
for (i = mediaBlockCount; i < context.mediaBlocks.length; i++) {
|
178
|
+
context.mediaBlocks[i].bubbleSelectors(selectors);
|
179
|
+
}
|
180
|
+
}
|
181
|
+
|
182
|
+
return ruleset;
|
183
|
+
};
|
184
|
+
Ruleset.prototype.evalImports = function(context) {
|
185
|
+
var rules = this.rules, i, importRules;
|
186
|
+
if (!rules) { return; }
|
187
|
+
|
188
|
+
for (i = 0; i < rules.length; i++) {
|
189
|
+
if (rules[i].type === "Import") {
|
190
|
+
importRules = rules[i].eval(context);
|
191
|
+
if (importRules && (importRules.length || importRules.length === 0)) {
|
192
|
+
rules.splice.apply(rules, [i, 1].concat(importRules));
|
193
|
+
i+= importRules.length - 1;
|
194
|
+
} else {
|
195
|
+
rules.splice(i, 1, importRules);
|
196
|
+
}
|
197
|
+
this.resetCache();
|
198
|
+
}
|
199
|
+
}
|
200
|
+
};
|
201
|
+
Ruleset.prototype.makeImportant = function() {
|
202
|
+
var result = new Ruleset(this.selectors, this.rules.map(function (r) {
|
203
|
+
if (r.makeImportant) {
|
204
|
+
return r.makeImportant();
|
205
|
+
} else {
|
206
|
+
return r;
|
207
|
+
}
|
208
|
+
}), this.strictImports, this.visibilityInfo());
|
209
|
+
|
210
|
+
return result;
|
211
|
+
};
|
212
|
+
Ruleset.prototype.matchArgs = function (args) {
|
213
|
+
return !args || args.length === 0;
|
214
|
+
};
|
215
|
+
// lets you call a css selector with a guard
|
216
|
+
Ruleset.prototype.matchCondition = function (args, context) {
|
217
|
+
var lastSelector = this.selectors[this.selectors.length - 1];
|
218
|
+
if (!lastSelector.evaldCondition) {
|
219
|
+
return false;
|
220
|
+
}
|
221
|
+
if (lastSelector.condition &&
|
222
|
+
!lastSelector.condition.eval(
|
223
|
+
new contexts.Eval(context,
|
224
|
+
context.frames))) {
|
225
|
+
return false;
|
226
|
+
}
|
227
|
+
return true;
|
228
|
+
};
|
229
|
+
Ruleset.prototype.resetCache = function () {
|
230
|
+
this._rulesets = null;
|
231
|
+
this._variables = null;
|
232
|
+
this._lookups = {};
|
233
|
+
};
|
234
|
+
Ruleset.prototype.variables = function () {
|
235
|
+
if (!this._variables) {
|
236
|
+
this._variables = !this.rules ? {} : this.rules.reduce(function (hash, r) {
|
237
|
+
if (r instanceof Rule && r.variable === true) {
|
238
|
+
hash[r.name] = r;
|
239
|
+
}
|
240
|
+
// when evaluating variables in an import statement, imports have not been eval'd
|
241
|
+
// so we need to go inside import statements.
|
242
|
+
// guard against root being a string (in the case of inlined less)
|
243
|
+
if (r.type === "Import" && r.root && r.root.variables) {
|
244
|
+
var vars = r.root.variables();
|
245
|
+
for (var name in vars) {
|
246
|
+
if (vars.hasOwnProperty(name)) {
|
247
|
+
hash[name] = vars[name];
|
248
|
+
}
|
249
|
+
}
|
250
|
+
}
|
251
|
+
return hash;
|
252
|
+
}, {});
|
253
|
+
}
|
254
|
+
return this._variables;
|
255
|
+
};
|
256
|
+
Ruleset.prototype.variable = function (name) {
|
257
|
+
return this.variables()[name];
|
258
|
+
};
|
259
|
+
Ruleset.prototype.rulesets = function () {
|
260
|
+
if (!this.rules) { return []; }
|
261
|
+
|
262
|
+
var filtRules = [], rules = this.rules, cnt = rules.length,
|
263
|
+
i, rule;
|
264
|
+
|
265
|
+
for (i = 0; i < cnt; i++) {
|
266
|
+
rule = rules[i];
|
267
|
+
if (rule.isRuleset) {
|
268
|
+
filtRules.push(rule);
|
269
|
+
}
|
270
|
+
}
|
271
|
+
|
272
|
+
return filtRules;
|
273
|
+
};
|
274
|
+
Ruleset.prototype.prependRule = function (rule) {
|
275
|
+
var rules = this.rules;
|
276
|
+
if (rules) {
|
277
|
+
rules.unshift(rule);
|
278
|
+
} else {
|
279
|
+
this.rules = [ rule ];
|
280
|
+
}
|
281
|
+
};
|
282
|
+
Ruleset.prototype.find = function (selector, self, filter) {
|
283
|
+
self = self || this;
|
284
|
+
var rules = [], match, foundMixins,
|
285
|
+
key = selector.toCSS();
|
286
|
+
|
287
|
+
if (key in this._lookups) { return this._lookups[key]; }
|
288
|
+
|
289
|
+
this.rulesets().forEach(function (rule) {
|
290
|
+
if (rule !== self) {
|
291
|
+
for (var j = 0; j < rule.selectors.length; j++) {
|
292
|
+
match = selector.match(rule.selectors[j]);
|
293
|
+
if (match) {
|
294
|
+
if (selector.elements.length > match) {
|
295
|
+
if (!filter || filter(rule)) {
|
296
|
+
foundMixins = rule.find(new Selector(selector.elements.slice(match)), self, filter);
|
297
|
+
for (var i = 0; i < foundMixins.length; ++i) {
|
298
|
+
foundMixins[i].path.push(rule);
|
299
|
+
}
|
300
|
+
Array.prototype.push.apply(rules, foundMixins);
|
301
|
+
}
|
302
|
+
} else {
|
303
|
+
rules.push({ rule: rule, path: []});
|
304
|
+
}
|
305
|
+
break;
|
306
|
+
}
|
307
|
+
}
|
308
|
+
}
|
309
|
+
});
|
310
|
+
this._lookups[key] = rules;
|
311
|
+
return rules;
|
312
|
+
};
|
313
|
+
Ruleset.prototype.genCSS = function (context, output) {
|
314
|
+
var i, j,
|
315
|
+
charsetRuleNodes = [],
|
316
|
+
ruleNodes = [],
|
317
|
+
debugInfo, // Line number debugging
|
318
|
+
rule,
|
319
|
+
path;
|
320
|
+
|
321
|
+
context.tabLevel = (context.tabLevel || 0);
|
322
|
+
|
323
|
+
if (!this.root) {
|
324
|
+
context.tabLevel++;
|
325
|
+
}
|
326
|
+
|
327
|
+
var tabRuleStr = context.compress ? '' : Array(context.tabLevel + 1).join(" "),
|
328
|
+
tabSetStr = context.compress ? '' : Array(context.tabLevel).join(" "),
|
329
|
+
sep;
|
330
|
+
|
331
|
+
function isRulesetLikeNode(rule) {
|
332
|
+
// if it has nested rules, then it should be treated like a ruleset
|
333
|
+
// medias and comments do not have nested rules, but should be treated like rulesets anyway
|
334
|
+
// some directives and anonymous nodes are ruleset like, others are not
|
335
|
+
if (typeof rule.isRulesetLike === "boolean") {
|
336
|
+
return rule.isRulesetLike;
|
337
|
+
} else if (typeof rule.isRulesetLike === "function") {
|
338
|
+
return rule.isRulesetLike();
|
339
|
+
}
|
340
|
+
|
341
|
+
//anything else is assumed to be a rule
|
342
|
+
return false;
|
343
|
+
}
|
344
|
+
|
345
|
+
var charsetNodeIndex = 0;
|
346
|
+
var importNodeIndex = 0;
|
347
|
+
for (i = 0; i < this.rules.length; i++) {
|
348
|
+
rule = this.rules[i];
|
349
|
+
if (rule.type === "Comment") {
|
350
|
+
if (importNodeIndex === i) {
|
351
|
+
importNodeIndex++;
|
352
|
+
}
|
353
|
+
ruleNodes.push(rule);
|
354
|
+
} else if (rule.isCharset && rule.isCharset()) {
|
355
|
+
ruleNodes.splice(charsetNodeIndex, 0, rule);
|
356
|
+
charsetNodeIndex++;
|
357
|
+
importNodeIndex++;
|
358
|
+
} else if (rule.type === "Import") {
|
359
|
+
ruleNodes.splice(importNodeIndex, 0, rule);
|
360
|
+
importNodeIndex++;
|
361
|
+
} else {
|
362
|
+
ruleNodes.push(rule);
|
363
|
+
}
|
364
|
+
}
|
365
|
+
ruleNodes = charsetRuleNodes.concat(ruleNodes);
|
366
|
+
|
367
|
+
// If this is the root node, we don't render
|
368
|
+
// a selector, or {}.
|
369
|
+
if (!this.root) {
|
370
|
+
debugInfo = getDebugInfo(context, this, tabSetStr);
|
371
|
+
|
372
|
+
if (debugInfo) {
|
373
|
+
output.add(debugInfo);
|
374
|
+
output.add(tabSetStr);
|
375
|
+
}
|
376
|
+
|
377
|
+
var paths = this.paths, pathCnt = paths.length,
|
378
|
+
pathSubCnt;
|
379
|
+
|
380
|
+
sep = context.compress ? ',' : (',\n' + tabSetStr);
|
381
|
+
|
382
|
+
for (i = 0; i < pathCnt; i++) {
|
383
|
+
path = paths[i];
|
384
|
+
if (!(pathSubCnt = path.length)) { continue; }
|
385
|
+
if (i > 0) { output.add(sep); }
|
386
|
+
|
387
|
+
context.firstSelector = true;
|
388
|
+
path[0].genCSS(context, output);
|
389
|
+
|
390
|
+
context.firstSelector = false;
|
391
|
+
for (j = 1; j < pathSubCnt; j++) {
|
392
|
+
path[j].genCSS(context, output);
|
393
|
+
}
|
394
|
+
}
|
395
|
+
|
396
|
+
output.add((context.compress ? '{' : ' {\n') + tabRuleStr);
|
397
|
+
}
|
398
|
+
|
399
|
+
// Compile rules and rulesets
|
400
|
+
for (i = 0; i < ruleNodes.length; i++) {
|
401
|
+
rule = ruleNodes[i];
|
402
|
+
|
403
|
+
if (i + 1 === ruleNodes.length) {
|
404
|
+
context.lastRule = true;
|
405
|
+
}
|
406
|
+
|
407
|
+
var currentLastRule = context.lastRule;
|
408
|
+
if (isRulesetLikeNode(rule)) {
|
409
|
+
context.lastRule = false;
|
410
|
+
}
|
411
|
+
|
412
|
+
if (rule.genCSS) {
|
413
|
+
rule.genCSS(context, output);
|
414
|
+
} else if (rule.value) {
|
415
|
+
output.add(rule.value.toString());
|
416
|
+
}
|
417
|
+
|
418
|
+
context.lastRule = currentLastRule;
|
419
|
+
|
420
|
+
if (!context.lastRule) {
|
421
|
+
output.add(context.compress ? '' : ('\n' + tabRuleStr));
|
422
|
+
} else {
|
423
|
+
context.lastRule = false;
|
424
|
+
}
|
425
|
+
}
|
426
|
+
|
427
|
+
if (!this.root) {
|
428
|
+
output.add((context.compress ? '}' : '\n' + tabSetStr + '}'));
|
429
|
+
context.tabLevel--;
|
430
|
+
}
|
431
|
+
|
432
|
+
if (!output.isEmpty() && !context.compress && this.firstRoot) {
|
433
|
+
output.add('\n');
|
434
|
+
}
|
435
|
+
};
|
436
|
+
|
437
|
+
Ruleset.prototype.joinSelectors = function (paths, context, selectors) {
|
438
|
+
for (var s = 0; s < selectors.length; s++) {
|
439
|
+
this.joinSelector(paths, context, selectors[s]);
|
440
|
+
}
|
441
|
+
};
|
442
|
+
|
443
|
+
Ruleset.prototype.joinSelector = function (paths, context, selector) {
|
444
|
+
|
445
|
+
function createParenthesis(elementsToPak, originalElement) {
|
446
|
+
var replacementParen, j;
|
447
|
+
if (elementsToPak.length === 0) {
|
448
|
+
replacementParen = new Paren(elementsToPak[0]);
|
449
|
+
} else {
|
450
|
+
var insideParent = [];
|
451
|
+
for (j = 0; j < elementsToPak.length; j++) {
|
452
|
+
insideParent.push(new Element(null, elementsToPak[j], originalElement.index, originalElement.currentFileInfo));
|
453
|
+
}
|
454
|
+
replacementParen = new Paren(new Selector(insideParent));
|
455
|
+
}
|
456
|
+
return replacementParen;
|
457
|
+
}
|
458
|
+
|
459
|
+
function createSelector(containedElement, originalElement) {
|
460
|
+
var element, selector;
|
461
|
+
element = new Element(null, containedElement, originalElement.index, originalElement.currentFileInfo);
|
462
|
+
selector = new Selector([element]);
|
463
|
+
return selector;
|
464
|
+
}
|
465
|
+
|
466
|
+
// joins selector path from `beginningPath` with selector path in `addPath`
|
467
|
+
// `replacedElement` contains element that is being replaced by `addPath`
|
468
|
+
// returns concatenated path
|
469
|
+
function addReplacementIntoPath(beginningPath, addPath, replacedElement, originalSelector) {
|
470
|
+
var newSelectorPath, lastSelector, newJoinedSelector;
|
471
|
+
// our new selector path
|
472
|
+
newSelectorPath = [];
|
473
|
+
|
474
|
+
//construct the joined selector - if & is the first thing this will be empty,
|
475
|
+
// if not newJoinedSelector will be the last set of elements in the selector
|
476
|
+
if (beginningPath.length > 0) {
|
477
|
+
newSelectorPath = beginningPath.slice(0);
|
478
|
+
lastSelector = newSelectorPath.pop();
|
479
|
+
newJoinedSelector = originalSelector.createDerived(lastSelector.elements.slice(0));
|
480
|
+
}
|
481
|
+
else {
|
482
|
+
newJoinedSelector = originalSelector.createDerived([]);
|
483
|
+
}
|
484
|
+
|
485
|
+
if (addPath.length > 0) {
|
486
|
+
// /deep/ is a combinator that is valid without anything in front of it
|
487
|
+
// so if the & does not have a combinator that is "" or " " then
|
488
|
+
// and there is a combinator on the parent, then grab that.
|
489
|
+
// this also allows + a { & .b { .a & { ... though not sure why you would want to do that
|
490
|
+
var combinator = replacedElement.combinator, parentEl = addPath[0].elements[0];
|
491
|
+
if (combinator.emptyOrWhitespace && !parentEl.combinator.emptyOrWhitespace) {
|
492
|
+
combinator = parentEl.combinator;
|
493
|
+
}
|
494
|
+
// join the elements so far with the first part of the parent
|
495
|
+
newJoinedSelector.elements.push(new Element(combinator, parentEl.value, replacedElement.index, replacedElement.currentFileInfo));
|
496
|
+
newJoinedSelector.elements = newJoinedSelector.elements.concat(addPath[0].elements.slice(1));
|
497
|
+
}
|
498
|
+
|
499
|
+
// now add the joined selector - but only if it is not empty
|
500
|
+
if (newJoinedSelector.elements.length !== 0) {
|
501
|
+
newSelectorPath.push(newJoinedSelector);
|
502
|
+
}
|
503
|
+
|
504
|
+
//put together the parent selectors after the join (e.g. the rest of the parent)
|
505
|
+
if (addPath.length > 1) {
|
506
|
+
var restOfPath = addPath.slice(1);
|
507
|
+
restOfPath = restOfPath.map(function (selector) {
|
508
|
+
return selector.createDerived(selector.elements, []);
|
509
|
+
});
|
510
|
+
newSelectorPath = newSelectorPath.concat(restOfPath);
|
511
|
+
}
|
512
|
+
return newSelectorPath;
|
513
|
+
}
|
514
|
+
|
515
|
+
// joins selector path from `beginningPath` with every selector path in `addPaths` array
|
516
|
+
// `replacedElement` contains element that is being replaced by `addPath`
|
517
|
+
// returns array with all concatenated paths
|
518
|
+
function addAllReplacementsIntoPath( beginningPath, addPaths, replacedElement, originalSelector, result) {
|
519
|
+
var j;
|
520
|
+
for (j = 0; j < beginningPath.length; j++) {
|
521
|
+
var newSelectorPath = addReplacementIntoPath(beginningPath[j], addPaths, replacedElement, originalSelector);
|
522
|
+
result.push(newSelectorPath);
|
523
|
+
}
|
524
|
+
return result;
|
525
|
+
}
|
526
|
+
|
527
|
+
function mergeElementsOnToSelectors(elements, selectors) {
|
528
|
+
var i, sel;
|
529
|
+
|
530
|
+
if (elements.length === 0) {
|
531
|
+
return ;
|
532
|
+
}
|
533
|
+
if (selectors.length === 0) {
|
534
|
+
selectors.push([ new Selector(elements) ]);
|
535
|
+
return;
|
536
|
+
}
|
537
|
+
|
538
|
+
for (i = 0; i < selectors.length; i++) {
|
539
|
+
sel = selectors[i];
|
540
|
+
|
541
|
+
// if the previous thing in sel is a parent this needs to join on to it
|
542
|
+
if (sel.length > 0) {
|
543
|
+
sel[sel.length - 1] = sel[sel.length - 1].createDerived(sel[sel.length - 1].elements.concat(elements));
|
544
|
+
}
|
545
|
+
else {
|
546
|
+
sel.push(new Selector(elements));
|
547
|
+
}
|
548
|
+
}
|
549
|
+
}
|
550
|
+
|
551
|
+
// replace all parent selectors inside `inSelector` by content of `context` array
|
552
|
+
// resulting selectors are returned inside `paths` array
|
553
|
+
// returns true if `inSelector` contained at least one parent selector
|
554
|
+
function replaceParentSelector(paths, context, inSelector) {
|
555
|
+
// The paths are [[Selector]]
|
556
|
+
// The first list is a list of comma separated selectors
|
557
|
+
// The inner list is a list of inheritance separated selectors
|
558
|
+
// e.g.
|
559
|
+
// .a, .b {
|
560
|
+
// .c {
|
561
|
+
// }
|
562
|
+
// }
|
563
|
+
// == [[.a] [.c]] [[.b] [.c]]
|
564
|
+
//
|
565
|
+
var i, j, k, currentElements, newSelectors, selectorsMultiplied, sel, el, hadParentSelector = false, length, lastSelector;
|
566
|
+
function findNestedSelector(element) {
|
567
|
+
var maybeSelector;
|
568
|
+
if (element.value.type !== 'Paren') {
|
569
|
+
return null;
|
570
|
+
}
|
571
|
+
|
572
|
+
maybeSelector = element.value.value;
|
573
|
+
if (maybeSelector.type !== 'Selector') {
|
574
|
+
return null;
|
575
|
+
}
|
576
|
+
|
577
|
+
return maybeSelector;
|
578
|
+
}
|
579
|
+
|
580
|
+
// the elements from the current selector so far
|
581
|
+
currentElements = [];
|
582
|
+
// the current list of new selectors to add to the path.
|
583
|
+
// We will build it up. We initiate it with one empty selector as we "multiply" the new selectors
|
584
|
+
// by the parents
|
585
|
+
newSelectors = [
|
586
|
+
[]
|
587
|
+
];
|
588
|
+
|
589
|
+
for (i = 0; i < inSelector.elements.length; i++) {
|
590
|
+
el = inSelector.elements[i];
|
591
|
+
// non parent reference elements just get added
|
592
|
+
if (el.value !== "&") {
|
593
|
+
var nestedSelector = findNestedSelector(el);
|
594
|
+
if (nestedSelector != null) {
|
595
|
+
// merge the current list of non parent selector elements
|
596
|
+
// on to the current list of selectors to add
|
597
|
+
mergeElementsOnToSelectors(currentElements, newSelectors);
|
598
|
+
|
599
|
+
var nestedPaths = [], replaced, replacedNewSelectors = [];
|
600
|
+
replaced = replaceParentSelector(nestedPaths, context, nestedSelector);
|
601
|
+
hadParentSelector = hadParentSelector || replaced;
|
602
|
+
//the nestedPaths array should have only one member - replaceParentSelector does not multiply selectors
|
603
|
+
for (k = 0; k < nestedPaths.length; k++) {
|
604
|
+
var replacementSelector = createSelector(createParenthesis(nestedPaths[k], el), el);
|
605
|
+
addAllReplacementsIntoPath(newSelectors, [replacementSelector], el, inSelector, replacedNewSelectors);
|
606
|
+
}
|
607
|
+
newSelectors = replacedNewSelectors;
|
608
|
+
currentElements = [];
|
609
|
+
|
610
|
+
} else {
|
611
|
+
currentElements.push(el);
|
612
|
+
}
|
613
|
+
|
614
|
+
} else {
|
615
|
+
hadParentSelector = true;
|
616
|
+
// the new list of selectors to add
|
617
|
+
selectorsMultiplied = [];
|
618
|
+
|
619
|
+
// merge the current list of non parent selector elements
|
620
|
+
// on to the current list of selectors to add
|
621
|
+
mergeElementsOnToSelectors(currentElements, newSelectors);
|
622
|
+
|
623
|
+
// loop through our current selectors
|
624
|
+
for (j = 0; j < newSelectors.length; j++) {
|
625
|
+
sel = newSelectors[j];
|
626
|
+
// if we don't have any parent paths, the & might be in a mixin so that it can be used
|
627
|
+
// whether there are parents or not
|
628
|
+
if (context.length === 0) {
|
629
|
+
// the combinator used on el should now be applied to the next element instead so that
|
630
|
+
// it is not lost
|
631
|
+
if (sel.length > 0) {
|
632
|
+
sel[0].elements.push(new Element(el.combinator, '', el.index, el.currentFileInfo));
|
633
|
+
}
|
634
|
+
selectorsMultiplied.push(sel);
|
635
|
+
}
|
636
|
+
else {
|
637
|
+
// and the parent selectors
|
638
|
+
for (k = 0; k < context.length; k++) {
|
639
|
+
// We need to put the current selectors
|
640
|
+
// then join the last selector's elements on to the parents selectors
|
641
|
+
var newSelectorPath = addReplacementIntoPath(sel, context[k], el, inSelector);
|
642
|
+
// add that to our new set of selectors
|
643
|
+
selectorsMultiplied.push(newSelectorPath);
|
644
|
+
}
|
645
|
+
}
|
646
|
+
}
|
647
|
+
|
648
|
+
// our new selectors has been multiplied, so reset the state
|
649
|
+
newSelectors = selectorsMultiplied;
|
650
|
+
currentElements = [];
|
651
|
+
}
|
652
|
+
}
|
653
|
+
|
654
|
+
// if we have any elements left over (e.g. .a& .b == .b)
|
655
|
+
// add them on to all the current selectors
|
656
|
+
mergeElementsOnToSelectors(currentElements, newSelectors);
|
657
|
+
|
658
|
+
for (i = 0; i < newSelectors.length; i++) {
|
659
|
+
length = newSelectors[i].length;
|
660
|
+
if (length > 0) {
|
661
|
+
paths.push(newSelectors[i]);
|
662
|
+
lastSelector = newSelectors[i][length - 1];
|
663
|
+
newSelectors[i][length - 1] = lastSelector.createDerived(lastSelector.elements, inSelector.extendList);
|
664
|
+
//newSelectors[i][length - 1].copyVisibilityInfo(inSelector.visibilityInfo());
|
665
|
+
}
|
666
|
+
}
|
667
|
+
|
668
|
+
return hadParentSelector;
|
669
|
+
}
|
670
|
+
|
671
|
+
function deriveSelector(visibilityInfo, deriveFrom) {
|
672
|
+
var newSelector = deriveFrom.createDerived(deriveFrom.elements, deriveFrom.extendList, deriveFrom.evaldCondition);
|
673
|
+
newSelector.copyVisibilityInfo(visibilityInfo);
|
674
|
+
return newSelector;
|
675
|
+
}
|
676
|
+
|
677
|
+
// joinSelector code follows
|
678
|
+
var i, newPaths, hadParentSelector;
|
679
|
+
|
680
|
+
newPaths = [];
|
681
|
+
hadParentSelector = replaceParentSelector(newPaths, context, selector);
|
682
|
+
|
683
|
+
if (!hadParentSelector) {
|
684
|
+
if (context.length > 0) {
|
685
|
+
newPaths = [];
|
686
|
+
for (i = 0; i < context.length; i++) {
|
687
|
+
//var concatenated = [];
|
688
|
+
//context[i].forEach(function(entry) {
|
689
|
+
// var newEntry = entry.createDerived(entry.elements, entry.extendList, entry.evaldCondition);
|
690
|
+
// newEntry.copyVisibilityInfo(selector.visibilityInfo());
|
691
|
+
// concatenated.push(newEntry);
|
692
|
+
//}, this);
|
693
|
+
var concatenated = context[i].map(deriveSelector.bind(this, selector.visibilityInfo()));
|
694
|
+
|
695
|
+
concatenated.push(selector);
|
696
|
+
newPaths.push(concatenated);
|
697
|
+
}
|
698
|
+
}
|
699
|
+
else {
|
700
|
+
newPaths = [[selector]];
|
701
|
+
}
|
702
|
+
}
|
703
|
+
|
704
|
+
for (i = 0; i < newPaths.length; i++) {
|
705
|
+
paths.push(newPaths[i]);
|
706
|
+
}
|
707
|
+
|
708
|
+
};
|
709
|
+
module.exports = Ruleset;
|