less 2.4.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +4 -0
- data/Gemfile +1 -1
- data/less.gemspec +1 -1
- data/lib/less/defaults.rb +3 -3
- data/lib/less/java_script/v8_context.rb +1 -1
- data/lib/less/js/.gitattributes +3 -2
- data/lib/less/js/.gitignore +18 -2
- data/lib/less/js/.jshintrc +11 -0
- data/lib/less/js/CHANGELOG.md +87 -2
- data/lib/less/js/CONTRIBUTING.md +4 -3
- data/lib/less/js/Gruntfile.js +290 -0
- data/lib/less/js/README.md +342 -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 +154 -12
- data/lib/less/js/bower.json +18 -0
- data/lib/less/js/build.gradle +347 -0
- data/lib/less/js/build/README.md +350 -0
- data/lib/less/js/build/browser-header.js +4 -0
- data/lib/less/js/build/build.yml +160 -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/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-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/lessc-rhino-1.6.2.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 +482 -367
- data/lib/less/js/lib/less/colors.js +0 -1
- data/lib/less/js/lib/less/encoder.js +4 -0
- data/lib/less/js/lib/less/env.js +50 -19
- data/lib/less/js/lib/less/extend-visitor.js +66 -41
- data/lib/less/js/lib/less/functions.js +309 -104
- data/lib/less/js/lib/less/import-visitor.js +21 -10
- data/lib/less/js/lib/less/index.js +90 -68
- data/lib/less/js/lib/less/join-selector-visitor.js +11 -4
- data/lib/less/js/lib/less/lessc_helper.js +56 -45
- data/lib/less/js/lib/less/parser.js +830 -460
- data/lib/less/js/lib/less/rhino.js +380 -58
- data/lib/less/js/lib/less/source-map-output.js +141 -0
- data/lib/less/js/lib/less/to-css-visitor.js +215 -0
- data/lib/less/js/lib/less/tree.js +57 -5
- data/lib/less/js/lib/less/tree/alpha.js +13 -5
- data/lib/less/js/lib/less/tree/anonymous.js +11 -5
- data/lib/less/js/lib/less/tree/assignment.js +11 -5
- data/lib/less/js/lib/less/tree/call.js +19 -8
- data/lib/less/js/lib/less/tree/color.js +59 -36
- data/lib/less/js/lib/less/tree/comment.js +17 -4
- data/lib/less/js/lib/less/tree/condition.js +3 -3
- data/lib/less/js/lib/less/tree/dimension.js +161 -153
- data/lib/less/js/lib/less/tree/directive.js +39 -18
- data/lib/less/js/lib/less/tree/element.js +41 -18
- data/lib/less/js/lib/less/tree/expression.js +11 -5
- data/lib/less/js/lib/less/tree/extend.js +11 -1
- data/lib/less/js/lib/less/tree/import.js +34 -20
- data/lib/less/js/lib/less/tree/javascript.js +16 -10
- data/lib/less/js/lib/less/tree/keyword.js +5 -2
- data/lib/less/js/lib/less/tree/media.js +39 -22
- data/lib/less/js/lib/less/tree/mixin.js +135 -56
- data/lib/less/js/lib/less/tree/negative.js +4 -2
- data/lib/less/js/lib/less/tree/operation.js +17 -12
- data/lib/less/js/lib/less/tree/paren.js +5 -2
- data/lib/less/js/lib/less/tree/quoted.js +9 -6
- data/lib/less/js/lib/less/tree/rule.js +39 -21
- data/lib/less/js/lib/less/tree/ruleset.js +229 -145
- data/lib/less/js/lib/less/tree/selector.js +101 -34
- data/lib/less/js/lib/less/tree/unicode-descriptor.js +4 -3
- data/lib/less/js/lib/less/tree/url.js +33 -11
- data/lib/less/js/lib/less/tree/value.js +13 -6
- data/lib/less/js/lib/less/tree/variable.js +13 -8
- data/lib/less/js/lib/less/visitor.js +117 -25
- 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 +30 -15
- data/lib/less/js/test/browser/common.js +131 -56
- 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/relative-urls/urls.css +8 -9
- data/lib/less/js/test/browser/css/rootpath-relative/urls.css +0 -1
- data/lib/less/js/test/browser/css/rootpath/urls.css +0 -1
- data/lib/less/js/test/browser/css/urls.css +18 -14
- data/lib/less/js/test/browser/es5.js +27 -0
- data/lib/less/js/test/{less/errors/color-operation-error.less → browser/less/console-errors/test-error.less} +0 -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/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/relative-urls/urls.less +1 -1
- data/lib/less/js/test/browser/less/rootpath-relative/urls.less +1 -1
- data/lib/less/js/test/browser/less/rootpath/urls.less +1 -1
- data/lib/less/js/test/browser/less/urls.less +9 -1
- data/lib/less/js/test/browser/phantom-runner.js +112 -103
- data/lib/less/js/test/browser/runner-browser-options.js +42 -0
- data/lib/less/js/test/browser/{runner-browser.js → runner-browser-spec.js} +7 -2
- 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.js → runner-legacy-spec.js} +1 -4
- 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-production-options.js +3 -0
- data/lib/less/js/test/browser/{runner-production.js → runner-production-spec.js} +1 -3
- data/lib/less/js/test/browser/runner-relative-urls-options.js +3 -0
- data/lib/less/js/test/browser/{runner-relative-urls.js → runner-relative-urls-spec.js} +1 -2
- 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.js → runner-rootpath-relative-spec.js} +1 -3
- data/lib/less/js/test/browser/{runner-rootpath.js → runner-rootpath-spec.js} +1 -2
- data/lib/less/js/test/browser/test-runner-template.tmpl +47 -0
- data/lib/less/js/test/css/colors.css +7 -0
- data/lib/less/js/test/css/comments.css +9 -4
- data/lib/less/js/test/css/compression/compression.css +3 -2
- data/lib/less/js/test/css/css-3.css +17 -5
- data/lib/less/js/test/css/css-guards.css +37 -0
- data/lib/less/js/test/css/debug/linenumbers-all.css +6 -0
- data/lib/less/js/test/css/debug/linenumbers-comments.css +5 -0
- data/lib/less/js/test/css/debug/linenumbers-mediaquery.css +5 -0
- data/lib/less/js/test/css/empty.css +0 -0
- data/lib/less/js/test/css/extend-chaining.css +9 -0
- data/lib/less/js/test/css/extend-selector.css +10 -2
- data/lib/less/js/test/css/extract-and-length.css +133 -0
- data/lib/less/js/test/css/functions.css +23 -10
- 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/import-inline.css +5 -0
- data/lib/less/js/test/css/import-once.css +12 -0
- data/lib/less/js/test/css/import-reference.css +49 -0
- data/lib/less/js/test/css/import.css +0 -2
- data/lib/less/js/test/css/media.css +21 -5
- data/lib/less/js/test/css/merge.css +26 -0
- data/lib/less/js/test/css/mixins-guards-default-func.css +129 -0
- data/lib/less/js/test/css/mixins-guards.css +6 -0
- data/lib/less/js/test/css/mixins-important.css +7 -0
- data/lib/less/js/test/css/mixins-interpolated.css +39 -0
- data/lib/less/js/test/css/mixins.css +20 -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 +3 -0
- data/lib/less/js/test/css/property-name-interp.css +20 -0
- data/lib/less/js/test/css/selectors.css +12 -0
- data/lib/less/js/test/css/static-urls/urls.css +7 -4
- data/lib/less/js/test/css/strings.css +3 -0
- data/lib/less/js/test/css/url-args/urls.css +56 -0
- data/lib/less/js/test/css/urls.css +21 -9
- data/lib/less/js/test/index.js +45 -0
- data/lib/less/js/test/less-test.js +234 -191
- data/lib/less/js/test/less/colors.less +6 -0
- data/lib/less/js/test/less/comments.less +7 -1
- data/lib/less/js/test/less/compression/compression.less +21 -1
- data/lib/less/js/test/less/css-3.less +12 -0
- data/lib/less/js/test/less/css-guards.less +99 -0
- data/lib/less/js/test/less/debug/linenumbers.less +11 -1
- data/lib/less/js/test/less/empty.less +0 -0
- data/lib/less/js/test/less/errors/add-mixed-units.txt +4 -2
- data/lib/less/js/test/less/errors/add-mixed-units2.txt +4 -2
- 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/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/import-subfolder2.txt +4 -2
- 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/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/parse-error-curly-bracket.less +4 -1
- data/lib/less/js/test/less/errors/parse-error-curly-bracket.txt +4 -2
- 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.txt +2 -2
- 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/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-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/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 +12 -0
- data/lib/less/js/test/less/extend-selector.less +15 -0
- data/lib/less/js/test/less/extract-and-length.less +133 -0
- data/lib/less/js/test/less/functions.less +15 -2
- 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/import-inline.less +2 -0
- data/lib/less/js/test/less/import-once.less +2 -0
- data/lib/less/js/test/less/import-reference.less +18 -0
- data/lib/less/js/test/less/import/import-and-relative-paths-test.less +11 -0
- data/lib/less/js/test/less/import/import-reference.less +43 -0
- data/lib/less/js/test/less/import/import-test-f.less +5 -0
- data/lib/less/js/test/less/import/invalid-css.less +1 -0
- data/lib/less/js/test/less/media.less +25 -1
- data/lib/less/js/test/less/merge.less +59 -0
- data/lib/less/js/test/less/mixins-args.less +10 -0
- data/lib/less/js/test/less/mixins-guards-default-func.less +195 -0
- data/lib/less/js/test/less/mixins-guards.less +16 -0
- data/lib/less/js/test/less/mixins-important.less +4 -1
- data/lib/less/js/test/less/mixins-interpolated.less +69 -0
- data/lib/less/js/test/less/mixins.less +27 -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/parens.less +4 -0
- data/lib/less/js/test/less/property-name-interp.less +53 -0
- data/lib/less/js/test/less/selectors.less +13 -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/strings.less +6 -0
- data/lib/less/js/test/less/url-args/urls.less +63 -0
- data/lib/less/js/test/less/urls.less +15 -0
- 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 +48 -40
- data/lib/less/version.rb +1 -1
- data/spec/less/parser_spec.rb +15 -15
- metadata +146 -40
- data/lib/less/js/Makefile +0 -102
- data/lib/less/js/build/header.js +0 -9
- data/lib/less/js/test/browser-test-prepare.js +0 -46
- data/lib/less/js/test/browser/runner-errors.js +0 -5
- data/lib/less/js/test/browser/runner-main.js +0 -15
- data/lib/less/js/test/browser/template.htm +0 -10
- data/lib/less/js/test/less/errors/color-operation-error.txt +0 -2
@@ -1,61 +1,128 @@
|
|
1
1
|
(function (tree) {
|
2
2
|
|
3
|
-
tree.Selector = function (elements, extendList) {
|
3
|
+
tree.Selector = function (elements, extendList, condition, index, currentFileInfo, isReferenced) {
|
4
4
|
this.elements = elements;
|
5
|
-
this.extendList = extendList
|
5
|
+
this.extendList = extendList;
|
6
|
+
this.condition = condition;
|
7
|
+
this.currentFileInfo = currentFileInfo || {};
|
8
|
+
this.isReferenced = isReferenced;
|
9
|
+
if (!condition) {
|
10
|
+
this.evaldCondition = true;
|
11
|
+
}
|
6
12
|
};
|
7
13
|
tree.Selector.prototype = {
|
8
14
|
type: "Selector",
|
9
15
|
accept: function (visitor) {
|
10
|
-
|
11
|
-
|
16
|
+
if (this.elements) {
|
17
|
+
this.elements = visitor.visitArray(this.elements);
|
18
|
+
}
|
19
|
+
if (this.extendList) {
|
20
|
+
this.extendList = visitor.visitArray(this.extendList);
|
21
|
+
}
|
22
|
+
if (this.condition) {
|
23
|
+
this.condition = visitor.visit(this.condition);
|
24
|
+
}
|
25
|
+
},
|
26
|
+
createDerived: function(elements, extendList, evaldCondition) {
|
27
|
+
evaldCondition = (evaldCondition != null) ? evaldCondition : this.evaldCondition;
|
28
|
+
var newSelector = new(tree.Selector)(elements, extendList || this.extendList, null, this.index, this.currentFileInfo, this.isReferenced);
|
29
|
+
newSelector.evaldCondition = evaldCondition;
|
30
|
+
newSelector.mediaEmpty = this.mediaEmpty;
|
31
|
+
return newSelector;
|
12
32
|
},
|
13
33
|
match: function (other) {
|
14
34
|
var elements = this.elements,
|
15
35
|
len = elements.length,
|
16
|
-
|
36
|
+
olen, i;
|
17
37
|
|
18
|
-
|
19
|
-
(other.elements.length && other.elements[0].value === "&") ? 1 : 0);
|
20
|
-
olen = oelements.length;
|
21
|
-
max = Math.min(len, olen);
|
38
|
+
other.CacheElements();
|
22
39
|
|
40
|
+
olen = other._elements.length;
|
23
41
|
if (olen === 0 || len < olen) {
|
24
|
-
return
|
42
|
+
return 0;
|
25
43
|
} else {
|
26
|
-
for (i = 0; i <
|
27
|
-
if (elements[i].value !==
|
28
|
-
return
|
44
|
+
for (i = 0; i < olen; i++) {
|
45
|
+
if (elements[i].value !== other._elements[i]) {
|
46
|
+
return 0;
|
29
47
|
}
|
30
48
|
}
|
31
49
|
}
|
32
|
-
|
33
|
-
|
34
|
-
eval: function (env) {
|
35
|
-
return new(tree.Selector)(this.elements.map(function (e) {
|
36
|
-
return e.eval(env);
|
37
|
-
}), this.extendList.map(function(extend) {
|
38
|
-
return extend.eval(env);
|
39
|
-
}));
|
50
|
+
|
51
|
+
return olen; // return number of matched elements
|
40
52
|
},
|
41
|
-
|
42
|
-
|
53
|
+
CacheElements: function(){
|
54
|
+
var css = '', len, v, i;
|
43
55
|
|
44
|
-
if
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
56
|
+
if( !this._elements ){
|
57
|
+
|
58
|
+
len = this.elements.length;
|
59
|
+
for(i = 0; i < len; i++){
|
60
|
+
|
61
|
+
v = this.elements[i];
|
62
|
+
css += v.combinator.value;
|
63
|
+
|
64
|
+
if( !v.value.value ){
|
65
|
+
css += v.value;
|
66
|
+
continue;
|
67
|
+
}
|
68
|
+
|
69
|
+
if( typeof v.value.value !== "string" ){
|
70
|
+
css = '';
|
71
|
+
break;
|
72
|
+
}
|
73
|
+
css += v.value.value;
|
74
|
+
}
|
75
|
+
|
76
|
+
this._elements = css.match(/[,&#\.\w-]([\w-]|(\\.))*/g);
|
77
|
+
|
78
|
+
if (this._elements) {
|
79
|
+
if (this._elements[0] === "&") {
|
80
|
+
this._elements.shift();
|
81
|
+
}
|
49
82
|
|
50
|
-
this._css += this.elements.map(function (e) {
|
51
|
-
if (typeof(e) === 'string') {
|
52
|
-
return ' ' + e.trim();
|
53
83
|
} else {
|
54
|
-
|
84
|
+
this._elements = [];
|
55
85
|
}
|
56
|
-
}).join('');
|
57
86
|
|
58
|
-
|
87
|
+
}
|
88
|
+
},
|
89
|
+
isJustParentSelector: function() {
|
90
|
+
return !this.mediaEmpty &&
|
91
|
+
this.elements.length === 1 &&
|
92
|
+
this.elements[0].value === '&' &&
|
93
|
+
(this.elements[0].combinator.value === ' ' || this.elements[0].combinator.value === '');
|
94
|
+
},
|
95
|
+
eval: function (env) {
|
96
|
+
var evaldCondition = this.condition && this.condition.eval(env),
|
97
|
+
elements = this.elements, extendList = this.extendList;
|
98
|
+
|
99
|
+
elements = elements && elements.map(function (e) { return e.eval(env); });
|
100
|
+
extendList = extendList && extendList.map(function(extend) { return extend.eval(env); });
|
101
|
+
|
102
|
+
return this.createDerived(elements, extendList, evaldCondition);
|
103
|
+
},
|
104
|
+
genCSS: function (env, output) {
|
105
|
+
var i, element;
|
106
|
+
if ((!env || !env.firstSelector) && this.elements[0].combinator.value === "") {
|
107
|
+
output.add(' ', this.currentFileInfo, this.index);
|
108
|
+
}
|
109
|
+
if (!this._css) {
|
110
|
+
//TODO caching? speed comparison?
|
111
|
+
for(i = 0; i < this.elements.length; i++) {
|
112
|
+
element = this.elements[i];
|
113
|
+
element.genCSS(env, output);
|
114
|
+
}
|
115
|
+
}
|
116
|
+
},
|
117
|
+
toCSS: tree.toCSS,
|
118
|
+
markReferenced: function () {
|
119
|
+
this.isReferenced = true;
|
120
|
+
},
|
121
|
+
getIsReferenced: function() {
|
122
|
+
return !this.currentFileInfo.reference || this.isReferenced;
|
123
|
+
},
|
124
|
+
getIsOutput: function() {
|
125
|
+
return this.evaldCondition;
|
59
126
|
}
|
60
127
|
};
|
61
128
|
|
@@ -5,10 +5,11 @@ tree.UnicodeDescriptor = function (value) {
|
|
5
5
|
};
|
6
6
|
tree.UnicodeDescriptor.prototype = {
|
7
7
|
type: "UnicodeDescriptor",
|
8
|
-
|
9
|
-
|
8
|
+
genCSS: function (env, output) {
|
9
|
+
output.add(this.value);
|
10
10
|
},
|
11
|
-
|
11
|
+
toCSS: tree.toCSS,
|
12
|
+
eval: function () { return this; }
|
12
13
|
};
|
13
14
|
|
14
15
|
})(require('../tree'));
|
@@ -1,30 +1,52 @@
|
|
1
1
|
(function (tree) {
|
2
2
|
|
3
|
-
tree.URL = function (val, currentFileInfo) {
|
3
|
+
tree.URL = function (val, currentFileInfo, isEvald) {
|
4
4
|
this.value = val;
|
5
5
|
this.currentFileInfo = currentFileInfo;
|
6
|
+
this.isEvald = isEvald;
|
6
7
|
};
|
7
8
|
tree.URL.prototype = {
|
8
9
|
type: "Url",
|
9
10
|
accept: function (visitor) {
|
10
11
|
this.value = visitor.visit(this.value);
|
11
12
|
},
|
12
|
-
|
13
|
-
|
13
|
+
genCSS: function (env, output) {
|
14
|
+
output.add("url(");
|
15
|
+
this.value.genCSS(env, output);
|
16
|
+
output.add(")");
|
14
17
|
},
|
18
|
+
toCSS: tree.toCSS,
|
15
19
|
eval: function (ctx) {
|
16
|
-
var val = this.value.eval(ctx),
|
20
|
+
var val = this.value.eval(ctx),
|
21
|
+
rootpath;
|
17
22
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
if (
|
22
|
-
|
23
|
+
if (!this.isEvald) {
|
24
|
+
// Add the base path if the URL is relative
|
25
|
+
rootpath = this.currentFileInfo && this.currentFileInfo.rootpath;
|
26
|
+
if (rootpath && typeof val.value === "string" && ctx.isPathRelative(val.value)) {
|
27
|
+
if (!val.quote) {
|
28
|
+
rootpath = rootpath.replace(/[\(\)'"\s]/g, function(match) { return "\\"+match; });
|
29
|
+
}
|
30
|
+
val.value = rootpath + val.value;
|
31
|
+
}
|
32
|
+
|
33
|
+
val.value = ctx.normalizePath(val.value);
|
34
|
+
|
35
|
+
// Add url args if enabled
|
36
|
+
if (ctx.urlArgs) {
|
37
|
+
if (!val.value.match(/^\s*data:/)) {
|
38
|
+
var delimiter = val.value.indexOf('?') === -1 ? '?' : '&';
|
39
|
+
var urlArgs = delimiter + ctx.urlArgs;
|
40
|
+
if (val.value.indexOf('#') !== -1) {
|
41
|
+
val.value = val.value.replace('#', urlArgs + '#');
|
42
|
+
} else {
|
43
|
+
val.value += urlArgs;
|
44
|
+
}
|
45
|
+
}
|
23
46
|
}
|
24
|
-
val.value = rootpath + val.value;
|
25
47
|
}
|
26
48
|
|
27
|
-
return new(tree.URL)(val,
|
49
|
+
return new(tree.URL)(val, this.currentFileInfo, true);
|
28
50
|
}
|
29
51
|
};
|
30
52
|
|
@@ -6,7 +6,9 @@ tree.Value = function (value) {
|
|
6
6
|
tree.Value.prototype = {
|
7
7
|
type: "Value",
|
8
8
|
accept: function (visitor) {
|
9
|
-
|
9
|
+
if (this.value) {
|
10
|
+
this.value = visitor.visitArray(this.value);
|
11
|
+
}
|
10
12
|
},
|
11
13
|
eval: function (env) {
|
12
14
|
if (this.value.length === 1) {
|
@@ -17,11 +19,16 @@ tree.Value.prototype = {
|
|
17
19
|
}));
|
18
20
|
}
|
19
21
|
},
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
genCSS: function (env, output) {
|
23
|
+
var i;
|
24
|
+
for(i = 0; i < this.value.length; i++) {
|
25
|
+
this.value[i].genCSS(env, output);
|
26
|
+
if (i+1 < this.value.length) {
|
27
|
+
output.add((env && env.compress) ? ',' : ', ');
|
28
|
+
}
|
29
|
+
}
|
30
|
+
},
|
31
|
+
toCSS: tree.toCSS
|
25
32
|
};
|
26
33
|
|
27
34
|
})(require('../tree'));
|
@@ -1,12 +1,16 @@
|
|
1
1
|
(function (tree) {
|
2
2
|
|
3
|
-
tree.Variable = function (name, index, currentFileInfo) {
|
3
|
+
tree.Variable = function (name, index, currentFileInfo) {
|
4
|
+
this.name = name;
|
5
|
+
this.index = index;
|
6
|
+
this.currentFileInfo = currentFileInfo || {};
|
7
|
+
};
|
4
8
|
tree.Variable.prototype = {
|
5
9
|
type: "Variable",
|
6
10
|
eval: function (env) {
|
7
|
-
var variable,
|
11
|
+
var variable, name = this.name;
|
8
12
|
|
9
|
-
if (name.indexOf('@@')
|
13
|
+
if (name.indexOf('@@') === 0) {
|
10
14
|
name = '@' + new(tree.Variable)(name.slice(1)).eval(env).value;
|
11
15
|
}
|
12
16
|
|
@@ -19,15 +23,16 @@ tree.Variable.prototype = {
|
|
19
23
|
|
20
24
|
this.evaluating = true;
|
21
25
|
|
22
|
-
|
23
|
-
|
26
|
+
variable = tree.find(env.frames, function (frame) {
|
27
|
+
var v = frame.variable(name);
|
28
|
+
if (v) {
|
24
29
|
return v.value.eval(env);
|
25
30
|
}
|
26
|
-
})
|
31
|
+
});
|
32
|
+
if (variable) {
|
27
33
|
this.evaluating = false;
|
28
34
|
return variable;
|
29
|
-
}
|
30
|
-
else {
|
35
|
+
} else {
|
31
36
|
throw { type: 'Name',
|
32
37
|
message: "variable " + name + " is undefined",
|
33
38
|
filename: this.currentFileInfo.filename,
|
@@ -1,53 +1,145 @@
|
|
1
1
|
(function (tree) {
|
2
2
|
|
3
|
+
var _visitArgs = { visitDeeper: true },
|
4
|
+
_hasIndexed = false;
|
5
|
+
|
6
|
+
function _noop(node) {
|
7
|
+
return node;
|
8
|
+
}
|
9
|
+
|
10
|
+
function indexNodeTypes(parent, ticker) {
|
11
|
+
// add .typeIndex to tree node types for lookup table
|
12
|
+
var key, child;
|
13
|
+
for (key in parent) {
|
14
|
+
if (parent.hasOwnProperty(key)) {
|
15
|
+
child = parent[key];
|
16
|
+
switch (typeof child) {
|
17
|
+
case "function":
|
18
|
+
// ignore bound functions directly on tree which do not have a prototype
|
19
|
+
// or aren't nodes
|
20
|
+
if (child.prototype && child.prototype.type) {
|
21
|
+
child.prototype.typeIndex = ticker++;
|
22
|
+
}
|
23
|
+
break;
|
24
|
+
case "object":
|
25
|
+
ticker = indexNodeTypes(child, ticker);
|
26
|
+
break;
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
return ticker;
|
31
|
+
}
|
32
|
+
|
3
33
|
tree.visitor = function(implementation) {
|
4
34
|
this._implementation = implementation;
|
35
|
+
this._visitFnCache = [];
|
36
|
+
|
37
|
+
if (!_hasIndexed) {
|
38
|
+
indexNodeTypes(tree, 1);
|
39
|
+
_hasIndexed = true;
|
40
|
+
}
|
5
41
|
};
|
6
42
|
|
7
43
|
tree.visitor.prototype = {
|
8
44
|
visit: function(node) {
|
9
|
-
|
10
|
-
|
11
|
-
return this.visitArray(node);
|
45
|
+
if (!node) {
|
46
|
+
return node;
|
12
47
|
}
|
13
48
|
|
14
|
-
|
49
|
+
var nodeTypeIndex = node.typeIndex;
|
50
|
+
if (!nodeTypeIndex) {
|
15
51
|
return node;
|
16
52
|
}
|
17
53
|
|
18
|
-
var
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
54
|
+
var visitFnCache = this._visitFnCache,
|
55
|
+
impl = this._implementation,
|
56
|
+
aryIndx = nodeTypeIndex << 1,
|
57
|
+
outAryIndex = aryIndx | 1,
|
58
|
+
func = visitFnCache[aryIndx],
|
59
|
+
funcOut = visitFnCache[outAryIndex],
|
60
|
+
visitArgs = _visitArgs,
|
61
|
+
fnName;
|
62
|
+
|
63
|
+
visitArgs.visitDeeper = true;
|
64
|
+
|
65
|
+
if (!func) {
|
66
|
+
fnName = "visit" + node.type;
|
67
|
+
func = impl[fnName] || _noop;
|
68
|
+
funcOut = impl[fnName + "Out"] || _noop;
|
69
|
+
visitFnCache[aryIndx] = func;
|
70
|
+
visitFnCache[outAryIndex] = funcOut;
|
71
|
+
}
|
72
|
+
|
73
|
+
if (func !== _noop) {
|
74
|
+
var newNode = func.call(impl, node, visitArgs);
|
75
|
+
if (impl.isReplacing) {
|
25
76
|
node = newNode;
|
26
77
|
}
|
27
78
|
}
|
28
|
-
|
79
|
+
|
80
|
+
if (visitArgs.visitDeeper && node && node.accept) {
|
29
81
|
node.accept(this);
|
30
82
|
}
|
31
|
-
|
32
|
-
if (
|
33
|
-
|
83
|
+
|
84
|
+
if (funcOut != _noop) {
|
85
|
+
funcOut.call(impl, node);
|
34
86
|
}
|
87
|
+
|
35
88
|
return node;
|
36
89
|
},
|
37
|
-
visitArray: function(nodes) {
|
38
|
-
|
39
|
-
|
90
|
+
visitArray: function(nodes, nonReplacing) {
|
91
|
+
if (!nodes) {
|
92
|
+
return nodes;
|
93
|
+
}
|
94
|
+
|
95
|
+
var cnt = nodes.length, i;
|
96
|
+
|
97
|
+
// Non-replacing
|
98
|
+
if (nonReplacing || !this._implementation.isReplacing) {
|
99
|
+
for (i = 0; i < cnt; i++) {
|
100
|
+
this.visit(nodes[i]);
|
101
|
+
}
|
102
|
+
return nodes;
|
103
|
+
}
|
104
|
+
|
105
|
+
// Replacing
|
106
|
+
var out = [];
|
107
|
+
for (i = 0; i < cnt; i++) {
|
40
108
|
var evald = this.visit(nodes[i]);
|
41
|
-
if (evald
|
42
|
-
|
43
|
-
} else {
|
44
|
-
|
109
|
+
if (!evald.splice) {
|
110
|
+
out.push(evald);
|
111
|
+
} else if (evald.length) {
|
112
|
+
this.flatten(evald, out);
|
45
113
|
}
|
46
114
|
}
|
47
|
-
|
48
|
-
|
115
|
+
return out;
|
116
|
+
},
|
117
|
+
flatten: function(arr, out) {
|
118
|
+
if (!out) {
|
119
|
+
out = [];
|
49
120
|
}
|
50
|
-
|
121
|
+
|
122
|
+
var cnt, i, item,
|
123
|
+
nestedCnt, j, nestedItem;
|
124
|
+
|
125
|
+
for (i = 0, cnt = arr.length; i < cnt; i++) {
|
126
|
+
item = arr[i];
|
127
|
+
if (!item.splice) {
|
128
|
+
out.push(item);
|
129
|
+
continue;
|
130
|
+
}
|
131
|
+
|
132
|
+
for (j = 0, nestedCnt = item.length; j < nestedCnt; j++) {
|
133
|
+
nestedItem = item[j];
|
134
|
+
if (!nestedItem.splice) {
|
135
|
+
out.push(nestedItem);
|
136
|
+
} else if (nestedItem.length) {
|
137
|
+
this.flatten(nestedItem, out);
|
138
|
+
}
|
139
|
+
}
|
140
|
+
}
|
141
|
+
|
142
|
+
return out;
|
51
143
|
}
|
52
144
|
};
|
53
145
|
|