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,44 +1,65 @@
|
|
1
1
|
(function (tree) {
|
2
2
|
|
3
|
-
tree.Directive = function (name, value) {
|
3
|
+
tree.Directive = function (name, value, index, currentFileInfo) {
|
4
4
|
this.name = name;
|
5
5
|
|
6
6
|
if (Array.isArray(value)) {
|
7
|
-
this.
|
8
|
-
this.
|
7
|
+
this.rules = [new(tree.Ruleset)(null, value)];
|
8
|
+
this.rules[0].allowImports = true;
|
9
9
|
} else {
|
10
10
|
this.value = value;
|
11
11
|
}
|
12
|
+
this.index = index;
|
13
|
+
this.currentFileInfo = currentFileInfo;
|
14
|
+
|
12
15
|
};
|
13
16
|
tree.Directive.prototype = {
|
14
17
|
type: "Directive",
|
15
18
|
accept: function (visitor) {
|
16
|
-
|
17
|
-
|
19
|
+
if (this.rules) {
|
20
|
+
this.rules = visitor.visitArray(this.rules);
|
21
|
+
}
|
22
|
+
if (this.value) {
|
23
|
+
this.value = visitor.visit(this.value);
|
24
|
+
}
|
18
25
|
},
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
this.ruleset.toCSS(env).trim().replace(/\n/g, '\n ') +
|
24
|
-
(env.compress ? '}': '\n}\n');
|
26
|
+
genCSS: function (env, output) {
|
27
|
+
output.add(this.name, this.currentFileInfo, this.index);
|
28
|
+
if (this.rules) {
|
29
|
+
tree.outputRuleset(env, output, this.rules);
|
25
30
|
} else {
|
26
|
-
|
31
|
+
output.add(' ');
|
32
|
+
this.value.genCSS(env, output);
|
33
|
+
output.add(';');
|
27
34
|
}
|
28
35
|
},
|
36
|
+
toCSS: tree.toCSS,
|
29
37
|
eval: function (env) {
|
30
38
|
var evaldDirective = this;
|
31
|
-
if (this.
|
39
|
+
if (this.rules) {
|
32
40
|
env.frames.unshift(this);
|
33
|
-
evaldDirective = new(tree.Directive)(this.name);
|
34
|
-
evaldDirective.
|
41
|
+
evaldDirective = new(tree.Directive)(this.name, null, this.index, this.currentFileInfo);
|
42
|
+
evaldDirective.rules = [this.rules[0].eval(env)];
|
43
|
+
evaldDirective.rules[0].root = true;
|
35
44
|
env.frames.shift();
|
36
45
|
}
|
37
46
|
return evaldDirective;
|
38
47
|
},
|
39
|
-
variable: function (name) { return tree.Ruleset.prototype.variable.call(this.
|
40
|
-
find: function () { return tree.Ruleset.prototype.find.apply(this.
|
41
|
-
rulesets: function () { return tree.Ruleset.prototype.rulesets.apply(this.
|
48
|
+
variable: function (name) { return tree.Ruleset.prototype.variable.call(this.rules[0], name); },
|
49
|
+
find: function () { return tree.Ruleset.prototype.find.apply(this.rules[0], arguments); },
|
50
|
+
rulesets: function () { return tree.Ruleset.prototype.rulesets.apply(this.rules[0]); },
|
51
|
+
markReferenced: function () {
|
52
|
+
var i, rules;
|
53
|
+
this.isReferenced = true;
|
54
|
+
if (this.rules) {
|
55
|
+
rules = this.rules[0].rules;
|
56
|
+
for (i = 0; i < rules.length; i++) {
|
57
|
+
if (rules[i].markReferenced) {
|
58
|
+
rules[i].markReferenced();
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}
|
42
63
|
};
|
43
64
|
|
44
65
|
})(require('../tree'));
|
@@ -1,6 +1,6 @@
|
|
1
1
|
(function (tree) {
|
2
2
|
|
3
|
-
tree.Element = function (combinator, value, index) {
|
3
|
+
tree.Element = function (combinator, value, index, currentFileInfo) {
|
4
4
|
this.combinator = combinator instanceof tree.Combinator ?
|
5
5
|
combinator : new(tree.Combinator)(combinator);
|
6
6
|
|
@@ -12,21 +12,29 @@ tree.Element = function (combinator, value, index) {
|
|
12
12
|
this.value = "";
|
13
13
|
}
|
14
14
|
this.index = index;
|
15
|
+
this.currentFileInfo = currentFileInfo;
|
15
16
|
};
|
16
17
|
tree.Element.prototype = {
|
17
18
|
type: "Element",
|
18
19
|
accept: function (visitor) {
|
20
|
+
var value = this.value;
|
19
21
|
this.combinator = visitor.visit(this.combinator);
|
20
|
-
|
22
|
+
if (typeof value === "object") {
|
23
|
+
this.value = visitor.visit(value);
|
24
|
+
}
|
21
25
|
},
|
22
26
|
eval: function (env) {
|
23
27
|
return new(tree.Element)(this.combinator,
|
24
28
|
this.value.eval ? this.value.eval(env) : this.value,
|
25
|
-
this.index
|
29
|
+
this.index,
|
30
|
+
this.currentFileInfo);
|
31
|
+
},
|
32
|
+
genCSS: function (env, output) {
|
33
|
+
output.add(this.toCSS(env), this.currentFileInfo, this.index);
|
26
34
|
},
|
27
35
|
toCSS: function (env) {
|
28
36
|
var value = (this.value.toCSS ? this.value.toCSS(env) : this.value);
|
29
|
-
if (value
|
37
|
+
if (value === '' && this.combinator.value.charAt(0) === '&') {
|
30
38
|
return '';
|
31
39
|
} else {
|
32
40
|
return this.combinator.toCSS(env || {}) + value;
|
@@ -41,13 +49,13 @@ tree.Attribute = function (key, op, value) {
|
|
41
49
|
};
|
42
50
|
tree.Attribute.prototype = {
|
43
51
|
type: "Attribute",
|
44
|
-
accept: function (visitor) {
|
45
|
-
this.value = visitor.visit(this.value);
|
46
|
-
},
|
47
52
|
eval: function (env) {
|
48
53
|
return new(tree.Attribute)(this.key.eval ? this.key.eval(env) : this.key,
|
49
54
|
this.op, (this.value && this.value.eval) ? this.value.eval(env) : this.value);
|
50
55
|
},
|
56
|
+
genCSS: function (env, output) {
|
57
|
+
output.add(this.toCSS(env));
|
58
|
+
},
|
51
59
|
toCSS: function (env) {
|
52
60
|
var value = this.key.toCSS ? this.key.toCSS(env) : this.key;
|
53
61
|
|
@@ -69,17 +77,32 @@ tree.Combinator = function (value) {
|
|
69
77
|
};
|
70
78
|
tree.Combinator.prototype = {
|
71
79
|
type: "Combinator",
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
}
|
80
|
+
_outputMap: {
|
81
|
+
'' : '',
|
82
|
+
' ' : ' ',
|
83
|
+
':' : ' :',
|
84
|
+
'+' : ' + ',
|
85
|
+
'~' : ' ~ ',
|
86
|
+
'>' : ' > ',
|
87
|
+
'|' : '|',
|
88
|
+
'^' : ' ^ ',
|
89
|
+
'^^' : ' ^^ '
|
90
|
+
},
|
91
|
+
_outputMapCompressed: {
|
92
|
+
'' : '',
|
93
|
+
' ' : ' ',
|
94
|
+
':' : ' :',
|
95
|
+
'+' : '+',
|
96
|
+
'~' : '~',
|
97
|
+
'>' : '>',
|
98
|
+
'|' : '|',
|
99
|
+
'^' : '^',
|
100
|
+
'^^' : '^^'
|
101
|
+
},
|
102
|
+
genCSS: function (env, output) {
|
103
|
+
output.add((env.compress ? this._outputMapCompressed : this._outputMap)[this.value]);
|
104
|
+
},
|
105
|
+
toCSS: tree.toCSS
|
83
106
|
};
|
84
107
|
|
85
108
|
})(require('../tree'));
|
@@ -4,7 +4,9 @@ tree.Expression = function (value) { this.value = value; };
|
|
4
4
|
tree.Expression.prototype = {
|
5
5
|
type: "Expression",
|
6
6
|
accept: function (visitor) {
|
7
|
-
|
7
|
+
if (this.value) {
|
8
|
+
this.value = visitor.visitArray(this.value);
|
9
|
+
}
|
8
10
|
},
|
9
11
|
eval: function (env) {
|
10
12
|
var returnValue,
|
@@ -33,11 +35,15 @@ tree.Expression.prototype = {
|
|
33
35
|
}
|
34
36
|
return returnValue;
|
35
37
|
},
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
38
|
+
genCSS: function (env, output) {
|
39
|
+
for(var i = 0; i < this.value.length; i++) {
|
40
|
+
this.value[i].genCSS(env, output);
|
41
|
+
if (i + 1 < this.value.length) {
|
42
|
+
output.add(" ");
|
43
|
+
}
|
44
|
+
}
|
40
45
|
},
|
46
|
+
toCSS: tree.toCSS,
|
41
47
|
throwAwayComments: function () {
|
42
48
|
this.value = this.value.filter(function(v) {
|
43
49
|
return !(v instanceof tree.Comment);
|
@@ -4,6 +4,8 @@ tree.Extend = function Extend(selector, option, index) {
|
|
4
4
|
this.selector = selector;
|
5
5
|
this.option = option;
|
6
6
|
this.index = index;
|
7
|
+
this.object_id = tree.Extend.next_id++;
|
8
|
+
this.parent_ids = [this.object_id];
|
7
9
|
|
8
10
|
switch(option) {
|
9
11
|
case "all":
|
@@ -16,6 +18,7 @@ tree.Extend = function Extend(selector, option, index) {
|
|
16
18
|
break;
|
17
19
|
}
|
18
20
|
};
|
21
|
+
tree.Extend.next_id = 0;
|
19
22
|
|
20
23
|
tree.Extend.prototype = {
|
21
24
|
type: "Extend",
|
@@ -30,9 +33,16 @@ tree.Extend.prototype = {
|
|
30
33
|
},
|
31
34
|
findSelfSelectors: function (selectors) {
|
32
35
|
var selfElements = [],
|
33
|
-
i
|
36
|
+
i,
|
37
|
+
selectorElements;
|
34
38
|
|
35
39
|
for(i = 0; i < selectors.length; i++) {
|
40
|
+
selectorElements = selectors[i].elements;
|
41
|
+
// duplicate the logic in genCSS function inside the selector node.
|
42
|
+
// future TODO - move both logics into the selector joiner visitor
|
43
|
+
if (i > 0 && selectorElements.length && selectorElements[0].combinator.value === "") {
|
44
|
+
selectorElements[0].combinator.value = ' ';
|
45
|
+
}
|
36
46
|
selfElements = selfElements.concat(selectors[i].elements);
|
37
47
|
}
|
38
48
|
|
@@ -12,16 +12,14 @@
|
|
12
12
|
// the file has been fetched, and parsed.
|
13
13
|
//
|
14
14
|
tree.Import = function (path, features, options, index, currentFileInfo) {
|
15
|
-
var that = this;
|
16
|
-
|
17
15
|
this.options = options;
|
18
16
|
this.index = index;
|
19
17
|
this.path = path;
|
20
18
|
this.features = features;
|
21
19
|
this.currentFileInfo = currentFileInfo;
|
22
20
|
|
23
|
-
if (this.options.less !== undefined) {
|
24
|
-
this.css = !this.options.less;
|
21
|
+
if (this.options.less !== undefined || this.options.inline) {
|
22
|
+
this.css = !this.options.less || this.options.inline;
|
25
23
|
} else {
|
26
24
|
var pathValue = this.getPath();
|
27
25
|
if (pathValue && /css([\?;].*)?$/.test(pathValue)) {
|
@@ -42,19 +40,26 @@ tree.Import = function (path, features, options, index, currentFileInfo) {
|
|
42
40
|
tree.Import.prototype = {
|
43
41
|
type: "Import",
|
44
42
|
accept: function (visitor) {
|
45
|
-
|
43
|
+
if (this.features) {
|
44
|
+
this.features = visitor.visit(this.features);
|
45
|
+
}
|
46
46
|
this.path = visitor.visit(this.path);
|
47
|
-
this.
|
47
|
+
if (!this.options.inline && this.root) {
|
48
|
+
this.root = visitor.visit(this.root);
|
49
|
+
}
|
48
50
|
},
|
49
|
-
|
50
|
-
var features = this.features ? ' ' + this.features.toCSS(env) : '';
|
51
|
-
|
51
|
+
genCSS: function (env, output) {
|
52
52
|
if (this.css) {
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
output.add("@import ", this.currentFileInfo, this.index);
|
54
|
+
this.path.genCSS(env, output);
|
55
|
+
if (this.features) {
|
56
|
+
output.add(" ");
|
57
|
+
this.features.genCSS(env, output);
|
58
|
+
}
|
59
|
+
output.add(';');
|
56
60
|
}
|
57
61
|
},
|
62
|
+
toCSS: tree.toCSS,
|
58
63
|
getPath: function () {
|
59
64
|
if (this.path instanceof tree.Quoted) {
|
60
65
|
var path = this.path.value;
|
@@ -70,28 +75,37 @@ tree.Import.prototype = {
|
|
70
75
|
evalPath: function (env) {
|
71
76
|
var path = this.path.eval(env);
|
72
77
|
var rootpath = this.currentFileInfo && this.currentFileInfo.rootpath;
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
path
|
78
|
+
|
79
|
+
if (!(path instanceof tree.URL)) {
|
80
|
+
if (rootpath) {
|
81
|
+
var pathValue = path.value;
|
82
|
+
// Add the base path if the import is relative
|
83
|
+
if (pathValue && env.isPathRelative(pathValue)) {
|
84
|
+
path.value = rootpath +pathValue;
|
85
|
+
}
|
78
86
|
}
|
87
|
+
path.value = env.normalizePath(path.value);
|
79
88
|
}
|
89
|
+
|
80
90
|
return path;
|
81
91
|
},
|
82
92
|
eval: function (env) {
|
83
93
|
var ruleset, features = this.features && this.features.eval(env);
|
84
94
|
|
85
95
|
if (this.skip) { return []; }
|
86
|
-
|
87
|
-
if (this.
|
96
|
+
|
97
|
+
if (this.options.inline) {
|
98
|
+
//todo needs to reference css file not import
|
99
|
+
var contents = new(tree.Anonymous)(this.root, 0, {filename: this.importedFilename}, true);
|
100
|
+
return this.features ? new(tree.Media)([contents], this.features.value) : [contents];
|
101
|
+
} else if (this.css) {
|
88
102
|
var newImport = new(tree.Import)(this.evalPath(env), features, this.options, this.index);
|
89
103
|
if (!newImport.css && this.error) {
|
90
104
|
throw this.error;
|
91
105
|
}
|
92
106
|
return newImport;
|
93
107
|
} else {
|
94
|
-
ruleset = new(tree.Ruleset)(
|
108
|
+
ruleset = new(tree.Ruleset)(null, this.root.rules.slice(0));
|
95
109
|
|
96
110
|
ruleset.evalImports(env);
|
97
111
|
|
@@ -19,26 +19,32 @@ tree.JavaScript.prototype = {
|
|
19
19
|
try {
|
20
20
|
expression = new(Function)('return (' + expression + ')');
|
21
21
|
} catch (e) {
|
22
|
-
throw { message: "JavaScript evaluation error: `" + expression + "`" ,
|
22
|
+
throw { message: "JavaScript evaluation error: " + e.message + " from `" + expression + "`" ,
|
23
23
|
index: this.index };
|
24
24
|
}
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
26
|
+
var variables = env.frames[0].variables();
|
27
|
+
for (var k in variables) {
|
28
|
+
if (variables.hasOwnProperty(k)) {
|
29
|
+
/*jshint loopfunc:true */
|
30
|
+
context[k.slice(1)] = {
|
31
|
+
value: variables[k].value,
|
32
|
+
toJS: function () {
|
33
|
+
return this.value.eval(env).toCSS();
|
34
|
+
}
|
35
|
+
};
|
36
|
+
}
|
33
37
|
}
|
34
38
|
|
35
39
|
try {
|
36
40
|
result = expression.call(context);
|
37
41
|
} catch (e) {
|
38
|
-
throw { message: "JavaScript evaluation error: '" + e.name + ': ' + e.message + "'" ,
|
42
|
+
throw { message: "JavaScript evaluation error: '" + e.name + ': ' + e.message.replace(/["]/g, "'") + "'" ,
|
39
43
|
index: this.index };
|
40
44
|
}
|
41
|
-
if (typeof(result) === '
|
45
|
+
if (typeof(result) === 'number') {
|
46
|
+
return new(tree.Dimension)(result);
|
47
|
+
} else if (typeof(result) === 'string') {
|
42
48
|
return new(tree.Quoted)('"' + result + '"', result, this.escaped, this.index);
|
43
49
|
} else if (Array.isArray(result)) {
|
44
50
|
return new(tree.Anonymous)(result.join(', '));
|
@@ -1,10 +1,13 @@
|
|
1
1
|
(function (tree) {
|
2
2
|
|
3
|
-
tree.Keyword = function (value) { this.value = value };
|
3
|
+
tree.Keyword = function (value) { this.value = value; };
|
4
4
|
tree.Keyword.prototype = {
|
5
5
|
type: "Keyword",
|
6
6
|
eval: function () { return this; },
|
7
|
-
|
7
|
+
genCSS: function (env, output) {
|
8
|
+
output.add(this.value);
|
9
|
+
},
|
10
|
+
toCSS: tree.toCSS,
|
8
11
|
compare: function (other) {
|
9
12
|
if (other instanceof tree.Keyword) {
|
10
13
|
return other.value === this.value ? 0 : 1;
|
@@ -1,34 +1,40 @@
|
|
1
1
|
(function (tree) {
|
2
2
|
|
3
|
-
tree.Media = function (value, features) {
|
3
|
+
tree.Media = function (value, features, index, currentFileInfo) {
|
4
|
+
this.index = index;
|
5
|
+
this.currentFileInfo = currentFileInfo;
|
6
|
+
|
4
7
|
var selectors = this.emptySelectors();
|
5
8
|
|
6
9
|
this.features = new(tree.Value)(features);
|
7
|
-
this.
|
8
|
-
this.
|
10
|
+
this.rules = [new(tree.Ruleset)(selectors, value)];
|
11
|
+
this.rules[0].allowImports = true;
|
9
12
|
};
|
10
13
|
tree.Media.prototype = {
|
11
14
|
type: "Media",
|
12
15
|
accept: function (visitor) {
|
13
|
-
|
14
|
-
|
16
|
+
if (this.features) {
|
17
|
+
this.features = visitor.visit(this.features);
|
18
|
+
}
|
19
|
+
if (this.rules) {
|
20
|
+
this.rules = visitor.visitArray(this.rules);
|
21
|
+
}
|
15
22
|
},
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
this.ruleset.toCSS(env).trim().replace(/\n/g, '\n ') +
|
21
|
-
(env.compress ? '}': '\n}\n');
|
23
|
+
genCSS: function (env, output) {
|
24
|
+
output.add('@media ', this.currentFileInfo, this.index);
|
25
|
+
this.features.genCSS(env, output);
|
26
|
+
tree.outputRuleset(env, output, this.rules);
|
22
27
|
},
|
28
|
+
toCSS: tree.toCSS,
|
23
29
|
eval: function (env) {
|
24
30
|
if (!env.mediaBlocks) {
|
25
31
|
env.mediaBlocks = [];
|
26
32
|
env.mediaPath = [];
|
27
33
|
}
|
28
34
|
|
29
|
-
var media = new(tree.Media)([],
|
35
|
+
var media = new(tree.Media)(null, [], this.index, this.currentFileInfo);
|
30
36
|
if(this.debugInfo) {
|
31
|
-
this.
|
37
|
+
this.rules[0].debugInfo = this.debugInfo;
|
32
38
|
media.debugInfo = this.debugInfo;
|
33
39
|
}
|
34
40
|
var strictMathBypass = false;
|
@@ -48,21 +54,32 @@ tree.Media.prototype = {
|
|
48
54
|
env.mediaPath.push(media);
|
49
55
|
env.mediaBlocks.push(media);
|
50
56
|
|
51
|
-
env.frames.unshift(this.
|
52
|
-
media.
|
57
|
+
env.frames.unshift(this.rules[0]);
|
58
|
+
media.rules = [this.rules[0].eval(env)];
|
53
59
|
env.frames.shift();
|
54
60
|
|
55
61
|
env.mediaPath.pop();
|
56
62
|
|
57
63
|
return env.mediaPath.length === 0 ? media.evalTop(env) :
|
58
|
-
media.evalNested(env)
|
64
|
+
media.evalNested(env);
|
59
65
|
},
|
60
|
-
variable: function (name) { return tree.Ruleset.prototype.variable.call(this.
|
61
|
-
find: function () { return tree.Ruleset.prototype.find.apply(this.
|
62
|
-
rulesets: function () { return tree.Ruleset.prototype.rulesets.apply(this.
|
66
|
+
variable: function (name) { return tree.Ruleset.prototype.variable.call(this.rules[0], name); },
|
67
|
+
find: function () { return tree.Ruleset.prototype.find.apply(this.rules[0], arguments); },
|
68
|
+
rulesets: function () { return tree.Ruleset.prototype.rulesets.apply(this.rules[0]); },
|
63
69
|
emptySelectors: function() {
|
64
|
-
var el = new(tree.Element)('', '&',
|
65
|
-
|
70
|
+
var el = new(tree.Element)('', '&', this.index, this.currentFileInfo),
|
71
|
+
sels = [new(tree.Selector)([el], null, null, this.index, this.currentFileInfo)];
|
72
|
+
sels[0].mediaEmpty = true;
|
73
|
+
return sels;
|
74
|
+
},
|
75
|
+
markReferenced: function () {
|
76
|
+
var i, rules = this.rules[0].rules;
|
77
|
+
this.isReferenced = true;
|
78
|
+
for (i = 0; i < rules.length; i++) {
|
79
|
+
if (rules[i].markReferenced) {
|
80
|
+
rules[i].markReferenced();
|
81
|
+
}
|
82
|
+
}
|
66
83
|
},
|
67
84
|
|
68
85
|
evalTop: function (env) {
|
@@ -130,7 +147,7 @@ tree.Media.prototype = {
|
|
130
147
|
}
|
131
148
|
},
|
132
149
|
bubbleSelectors: function (selectors) {
|
133
|
-
this.
|
150
|
+
this.rules = [new(tree.Ruleset)(selectors.slice(0), [this.rules[0]])];
|
134
151
|
}
|
135
152
|
};
|
136
153
|
|