less 4.5.1 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/lessc +37 -23
- package/dist/less.js +14497 -11745
- package/dist/less.min.js +4 -4
- package/dist/less.min.js.map +1 -1
- package/lib/less/constants.js +5 -7
- package/lib/less/contexts.js +71 -55
- package/lib/less/data/colors.js +150 -153
- package/lib/less/data/index.js +4 -7
- package/lib/less/data/unit-conversions.js +2 -5
- package/lib/less/default-options.js +36 -26
- package/lib/less/deprecation.js +67 -0
- package/lib/less/environment/abstract-file-manager.js +62 -50
- package/lib/less/environment/abstract-plugin-loader.js +69 -46
- package/lib/less/environment/environment-api.ts +21 -0
- package/lib/less/environment/environment.js +34 -30
- package/lib/less/environment/file-manager-api.ts +77 -0
- package/lib/less/functions/boolean.js +13 -13
- package/lib/less/functions/color-blending.js +39 -31
- package/lib/less/functions/color.js +153 -137
- package/lib/less/functions/data-uri.js +73 -64
- package/lib/less/functions/default.js +9 -11
- package/lib/less/functions/function-caller.js +35 -34
- package/lib/less/functions/function-registry.js +16 -17
- package/lib/less/functions/index.js +33 -33
- package/lib/less/functions/list.js +88 -75
- package/lib/less/functions/math-helper.js +8 -11
- package/lib/less/functions/math.js +21 -21
- package/lib/less/functions/number.js +42 -53
- package/lib/less/functions/string.js +18 -22
- package/lib/less/functions/style.js +21 -20
- package/lib/less/functions/svg.js +83 -82
- package/lib/less/functions/types.js +28 -32
- package/lib/less/import-manager.js +73 -64
- package/lib/less/index.js +65 -65
- package/lib/less/less-error.js +63 -45
- package/lib/less/logger.js +11 -14
- package/lib/less/parse-tree.js +52 -53
- package/lib/less/parse.js +44 -44
- package/lib/less/parser/parser-input.js +151 -113
- package/lib/less/parser/parser.js +864 -658
- package/lib/less/plugin-manager.js +57 -46
- package/lib/less/render.js +17 -23
- package/lib/less/source-map-builder.js +52 -43
- package/lib/less/source-map-output.js +56 -43
- package/lib/less/transform-tree.js +40 -30
- package/lib/less/tree/anonymous.js +52 -28
- package/lib/less/tree/assignment.js +44 -27
- package/lib/less/tree/atrule-syntax.js +4 -6
- package/lib/less/tree/atrule.js +247 -140
- package/lib/less/tree/attribute.js +55 -24
- package/lib/less/tree/call.js +70 -42
- package/lib/less/tree/color.js +194 -145
- package/lib/less/tree/combinator.js +31 -21
- package/lib/less/tree/comment.js +44 -23
- package/lib/less/tree/condition.js +61 -36
- package/lib/less/tree/container.js +90 -34
- package/lib/less/tree/debug-info.js +28 -15
- package/lib/less/tree/declaration.js +97 -52
- package/lib/less/tree/detached-ruleset.js +42 -24
- package/lib/less/tree/dimension.js +127 -71
- package/lib/less/tree/element.js +82 -52
- package/lib/less/tree/expression.js +75 -50
- package/lib/less/tree/extend.js +71 -42
- package/lib/less/tree/import.js +184 -110
- package/lib/less/tree/index.js +52 -81
- package/lib/less/tree/javascript.js +43 -32
- package/lib/less/tree/js-eval-node.js +46 -32
- package/lib/less/tree/keyword.js +25 -17
- package/lib/less/tree/media.js +77 -35
- package/lib/less/tree/merge-rules.js +47 -0
- package/lib/less/tree/mixin-call.js +181 -98
- package/lib/less/tree/mixin-definition.js +211 -117
- package/lib/less/tree/namespace-value.js +63 -44
- package/lib/less/tree/negative.js +34 -21
- package/lib/less/tree/nested-at-rule.js +149 -66
- package/lib/less/tree/node.js +225 -90
- package/lib/less/tree/operation.js +59 -34
- package/lib/less/tree/paren.js +34 -17
- package/lib/less/tree/property.js +66 -35
- package/lib/less/tree/query-in-parens.js +52 -60
- package/lib/less/tree/quoted.js +93 -44
- package/lib/less/tree/ruleset.js +632 -318
- package/lib/less/tree/selector.js +151 -77
- package/lib/less/tree/unicode-descriptor.js +14 -12
- package/lib/less/tree/unit.js +111 -63
- package/lib/less/tree/url.js +62 -38
- package/lib/less/tree/value.js +50 -34
- package/lib/less/tree/variable-call.js +47 -30
- package/lib/less/tree/variable.js +53 -31
- package/lib/less/utils.js +44 -47
- package/lib/less/visitors/extend-visitor.js +233 -172
- package/lib/less/visitors/import-sequencer.js +24 -24
- package/lib/less/visitors/import-visitor.js +62 -52
- package/lib/less/visitors/index.js +14 -17
- package/lib/less/visitors/join-selector-visitor.js +40 -37
- package/lib/less/visitors/set-tree-visibility-visitor.js +32 -18
- package/lib/less/visitors/to-css-visitor.js +135 -128
- package/lib/less/visitors/visitor.js +60 -45
- package/lib/less-browser/add-default-options.js +23 -13
- package/lib/less-browser/bootstrap.js +23 -17
- package/lib/less-browser/browser.js +24 -21
- package/lib/less-browser/cache.js +17 -19
- package/lib/less-browser/error-reporting.js +52 -44
- package/lib/less-browser/file-manager.js +52 -42
- package/lib/less-browser/image-size.js +12 -12
- package/lib/less-browser/index.js +131 -105
- package/lib/less-browser/log-listener.js +30 -31
- package/lib/less-browser/plugin-loader.js +10 -10
- package/lib/less-browser/utils.js +19 -21
- package/lib/less-node/environment.js +32 -8
- package/lib/less-node/file-manager.js +62 -45
- package/lib/less-node/fs.js +11 -8
- package/lib/less-node/image-size.js +40 -31
- package/lib/less-node/index.js +28 -19
- package/lib/less-node/lessc-helper.js +20 -21
- package/lib/less-node/plugin-loader.js +35 -27
- package/lib/less-node/url-file-manager.js +33 -31
- package/package.json +25 -18
- package/.eslintignore +0 -6
- package/.eslintrc.js +0 -63
- package/Gruntfile.js +0 -403
- package/bower.json +0 -22
- package/lib/less/constants.js.map +0 -1
- package/lib/less/contexts.js.map +0 -1
- package/lib/less/data/colors.js.map +0 -1
- package/lib/less/data/index.js.map +0 -1
- package/lib/less/data/unit-conversions.js.map +0 -1
- package/lib/less/default-options.js.map +0 -1
- package/lib/less/environment/abstract-file-manager.js.map +0 -1
- package/lib/less/environment/abstract-plugin-loader.js.map +0 -1
- package/lib/less/environment/environment-api.js +0 -3
- package/lib/less/environment/environment-api.js.map +0 -1
- package/lib/less/environment/environment.js.map +0 -1
- package/lib/less/environment/file-manager-api.js +0 -3
- package/lib/less/environment/file-manager-api.js.map +0 -1
- package/lib/less/functions/boolean.js.map +0 -1
- package/lib/less/functions/color-blending.js.map +0 -1
- package/lib/less/functions/color.js.map +0 -1
- package/lib/less/functions/data-uri.js.map +0 -1
- package/lib/less/functions/default.js.map +0 -1
- package/lib/less/functions/function-caller.js.map +0 -1
- package/lib/less/functions/function-registry.js.map +0 -1
- package/lib/less/functions/index.js.map +0 -1
- package/lib/less/functions/list.js.map +0 -1
- package/lib/less/functions/math-helper.js.map +0 -1
- package/lib/less/functions/math.js.map +0 -1
- package/lib/less/functions/number.js.map +0 -1
- package/lib/less/functions/string.js.map +0 -1
- package/lib/less/functions/style.js.map +0 -1
- package/lib/less/functions/svg.js.map +0 -1
- package/lib/less/functions/types.js.map +0 -1
- package/lib/less/import-manager.js.map +0 -1
- package/lib/less/index.js.map +0 -1
- package/lib/less/less-error.js.map +0 -1
- package/lib/less/logger.js.map +0 -1
- package/lib/less/parse-tree.js.map +0 -1
- package/lib/less/parse.js.map +0 -1
- package/lib/less/parser/parser-input.js.map +0 -1
- package/lib/less/parser/parser.js.map +0 -1
- package/lib/less/plugin-manager.js.map +0 -1
- package/lib/less/render.js.map +0 -1
- package/lib/less/source-map-builder.js.map +0 -1
- package/lib/less/source-map-output.js.map +0 -1
- package/lib/less/transform-tree.js.map +0 -1
- package/lib/less/tree/anonymous.js.map +0 -1
- package/lib/less/tree/assignment.js.map +0 -1
- package/lib/less/tree/atrule-syntax.js.map +0 -1
- package/lib/less/tree/atrule.js.map +0 -1
- package/lib/less/tree/attribute.js.map +0 -1
- package/lib/less/tree/call.js.map +0 -1
- package/lib/less/tree/color.js.map +0 -1
- package/lib/less/tree/combinator.js.map +0 -1
- package/lib/less/tree/comment.js.map +0 -1
- package/lib/less/tree/condition.js.map +0 -1
- package/lib/less/tree/container.js.map +0 -1
- package/lib/less/tree/debug-info.js.map +0 -1
- package/lib/less/tree/declaration.js.map +0 -1
- package/lib/less/tree/detached-ruleset.js.map +0 -1
- package/lib/less/tree/dimension.js.map +0 -1
- package/lib/less/tree/element.js.map +0 -1
- package/lib/less/tree/expression.js.map +0 -1
- package/lib/less/tree/extend.js.map +0 -1
- package/lib/less/tree/import.js.map +0 -1
- package/lib/less/tree/index.js.map +0 -1
- package/lib/less/tree/javascript.js.map +0 -1
- package/lib/less/tree/js-eval-node.js.map +0 -1
- package/lib/less/tree/keyword.js.map +0 -1
- package/lib/less/tree/media.js.map +0 -1
- package/lib/less/tree/mixin-call.js.map +0 -1
- package/lib/less/tree/mixin-definition.js.map +0 -1
- package/lib/less/tree/namespace-value.js.map +0 -1
- package/lib/less/tree/negative.js.map +0 -1
- package/lib/less/tree/nested-at-rule.js.map +0 -1
- package/lib/less/tree/node.js.map +0 -1
- package/lib/less/tree/operation.js.map +0 -1
- package/lib/less/tree/paren.js.map +0 -1
- package/lib/less/tree/property.js.map +0 -1
- package/lib/less/tree/query-in-parens.js.map +0 -1
- package/lib/less/tree/quoted.js.map +0 -1
- package/lib/less/tree/ruleset.js.map +0 -1
- package/lib/less/tree/selector.js.map +0 -1
- package/lib/less/tree/unicode-descriptor.js.map +0 -1
- package/lib/less/tree/unit.js.map +0 -1
- package/lib/less/tree/url.js.map +0 -1
- package/lib/less/tree/value.js.map +0 -1
- package/lib/less/tree/variable-call.js.map +0 -1
- package/lib/less/tree/variable.js.map +0 -1
- package/lib/less/utils.js.map +0 -1
- package/lib/less/visitors/extend-visitor.js.map +0 -1
- package/lib/less/visitors/import-sequencer.js.map +0 -1
- package/lib/less/visitors/import-visitor.js.map +0 -1
- package/lib/less/visitors/index.js.map +0 -1
- package/lib/less/visitors/join-selector-visitor.js.map +0 -1
- package/lib/less/visitors/set-tree-visibility-visitor.js.map +0 -1
- package/lib/less/visitors/to-css-visitor.js.map +0 -1
- package/lib/less/visitors/visitor.js.map +0 -1
- package/lib/less-browser/add-default-options.js.map +0 -1
- package/lib/less-browser/bootstrap.js.map +0 -1
- package/lib/less-browser/browser.js.map +0 -1
- package/lib/less-browser/cache.js.map +0 -1
- package/lib/less-browser/error-reporting.js.map +0 -1
- package/lib/less-browser/file-manager.js.map +0 -1
- package/lib/less-browser/image-size.js.map +0 -1
- package/lib/less-browser/index.js.map +0 -1
- package/lib/less-browser/log-listener.js.map +0 -1
- package/lib/less-browser/plugin-loader.js.map +0 -1
- package/lib/less-browser/utils.js.map +0 -1
- package/lib/less-node/environment.js.map +0 -1
- package/lib/less-node/file-manager.js.map +0 -1
- package/lib/less-node/fs.js.map +0 -1
- package/lib/less-node/image-size.js.map +0 -1
- package/lib/less-node/index.js.map +0 -1
- package/lib/less-node/lessc-helper.js.map +0 -1
- package/lib/less-node/plugin-loader.js.map +0 -1
- package/lib/less-node/url-file-manager.js.map +0 -1
- package/scripts/coverage-lines.js +0 -207
- package/scripts/coverage-report.js +0 -158
- package/scripts/postinstall.js +0 -61
- package/test/.eslintrc.json +0 -9
- package/test/README.md +0 -3
- package/test/browser/common.js +0 -251
- package/test/browser/css/global-vars/simple.css +0 -3
- package/test/browser/css/modify-vars/simple.css +0 -8
- package/test/browser/css/plugin/plugin.css +0 -3
- package/test/browser/css/postProcessor/postProcessor.css +0 -4
- package/test/browser/css/relative-urls/urls.css +0 -36
- package/test/browser/css/rewrite-urls/urls.css +0 -36
- package/test/browser/css/rootpath/urls.css +0 -35
- package/test/browser/css/rootpath-relative/urls.css +0 -35
- package/test/browser/css/rootpath-rewrite-urls/urls.css +0 -35
- package/test/browser/css/urls.css +0 -54
- package/test/browser/generator/benchmark.config.js +0 -50
- package/test/browser/generator/generate.js +0 -78
- package/test/browser/generator/runner.config.js +0 -184
- package/test/browser/generator/runner.js +0 -2
- package/test/browser/generator/template.js +0 -104
- package/test/browser/generator/utils.js +0 -14
- package/test/browser/less/console-errors/test-error.less +0 -3
- package/test/browser/less/console-errors/test-error.txt +0 -2
- package/test/browser/less/errors/image-height-error.less +0 -3
- package/test/browser/less/errors/image-height-error.txt +0 -4
- package/test/browser/less/errors/image-size-error.less +0 -3
- package/test/browser/less/errors/image-size-error.txt +0 -4
- package/test/browser/less/errors/image-width-error.less +0 -3
- package/test/browser/less/errors/image-width-error.txt +0 -4
- package/test/browser/less/global-vars/simple.less +0 -3
- package/test/browser/less/imports/urls.less +0 -4
- package/test/browser/less/imports/urls2.less +0 -4
- package/test/browser/less/modify-vars/imports/simple2.less +0 -4
- package/test/browser/less/modify-vars/simple.less +0 -8
- package/test/browser/less/nested-gradient-with-svg-gradient/mixin-consumer.less +0 -5
- package/test/browser/less/nested-gradient-with-svg-gradient/svg-gradient-mixin.less +0 -15
- package/test/browser/less/plugin/plugin.js +0 -4
- package/test/browser/less/plugin/plugin.less +0 -4
- package/test/browser/less/postProcessor/postProcessor.less +0 -4
- package/test/browser/less/relative-urls/urls.less +0 -34
- package/test/browser/less/rewrite-urls/urls.less +0 -34
- package/test/browser/less/rootpath/urls.less +0 -33
- package/test/browser/less/rootpath-relative/urls.less +0 -33
- package/test/browser/less/rootpath-rewrite-urls/urls.less +0 -33
- package/test/browser/less/urls.less +0 -62
- package/test/browser/runner-VisitorPlugin-options.js +0 -3
- package/test/browser/runner-VisitorPlugin.js +0 -3
- package/test/browser/runner-browser-options.js +0 -51
- package/test/browser/runner-browser-spec.js +0 -12
- package/test/browser/runner-console-errors.js +0 -5
- package/test/browser/runner-errors-options.js +0 -6
- package/test/browser/runner-errors-spec.js +0 -3
- package/test/browser/runner-filemanagerPlugin-options.js +0 -5
- package/test/browser/runner-filemanagerPlugin.js +0 -3
- package/test/browser/runner-global-vars-options.js +0 -7
- package/test/browser/runner-global-vars-spec.js +0 -3
- package/test/browser/runner-main-options.js +0 -17
- package/test/browser/runner-main-spec.js +0 -7
- package/test/browser/runner-modify-vars-options.js +0 -5
- package/test/browser/runner-modify-vars-spec.js +0 -33
- package/test/browser/runner-no-js-errors-options.js +0 -4
- package/test/browser/runner-no-js-errors-spec.js +0 -3
- package/test/browser/runner-postProcessorPlugin-options.js +0 -3
- package/test/browser/runner-postProcessorPlugin.js +0 -3
- package/test/browser/runner-preProcessorPlugin-options.js +0 -3
- package/test/browser/runner-preProcessorPlugin.js +0 -3
- package/test/browser/runner-production-options.js +0 -3
- package/test/browser/runner-production-spec.js +0 -5
- package/test/browser/runner-relative-urls-options.js +0 -3
- package/test/browser/runner-relative-urls-spec.js +0 -3
- package/test/browser/runner-rewrite-urls-options.js +0 -3
- package/test/browser/runner-rewrite-urls-spec.js +0 -3
- package/test/browser/runner-rootpath-options.js +0 -3
- package/test/browser/runner-rootpath-relative-options.js +0 -4
- package/test/browser/runner-rootpath-relative-spec.js +0 -3
- package/test/browser/runner-rootpath-rewrite-urls-options.js +0 -4
- package/test/browser/runner-rootpath-rewrite-urls-spec.js +0 -3
- package/test/browser/runner-rootpath-spec.js +0 -3
- package/test/browser/runner-strict-units-options.js +0 -5
- package/test/browser/runner-strict-units-spec.js +0 -3
- package/test/index.js +0 -307
- package/test/less-test.js +0 -984
- package/test/mocha-playwright/runner.js +0 -210
- package/test/modify-vars.js +0 -28
- package/test/plugins/filemanager/index.js +0 -19
- package/test/plugins/postprocess/index.js +0 -14
- package/test/plugins/preprocess/index.js +0 -19
- package/test/plugins/visitor/index.js +0 -24
- package/test/sourcemaps/basic.json +0 -1
- package/test/sourcemaps/comprehensive.json +0 -1
- package/test/sourcemaps/custom-props.json +0 -1
- package/test/sourcemaps/index.html +0 -17
- package/test/sourcemaps/sourcemaps-basepath.json +0 -1
- package/test/sourcemaps/sourcemaps-include-source.json +0 -1
- package/test/sourcemaps/sourcemaps-rootpath.json +0 -1
- package/test/sourcemaps/sourcemaps-url.json +0 -1
- package/test/sourcemaps-disable-annotation/basic.json +0 -1
- package/test/sourcemaps-variable-selector/basic.json +0 -1
- package/test/test-es6.ts +0 -17
- package/test.less +0 -1
- package/tsconfig.build.json +0 -7
- package/tsconfig.json +0 -21
|
@@ -1,134 +1,149 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var tslib_1 = require("tslib");
|
|
4
1
|
/* eslint-disable no-unused-vars */
|
|
5
2
|
/**
|
|
6
3
|
* @todo - Remove unused when JSDoc types are added for visitor methods
|
|
7
4
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
import tree from '../tree/index.js';
|
|
6
|
+
import Visitor from './visitor.js';
|
|
7
|
+
import logger from '../logger.js';
|
|
8
|
+
import * as utils from '../utils.js';
|
|
9
|
+
|
|
12
10
|
/* jshint loopfunc:true */
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
|
|
12
|
+
class ExtendFinderVisitor {
|
|
13
|
+
constructor() {
|
|
14
|
+
this._visitor = new Visitor(this);
|
|
16
15
|
this.contexts = [];
|
|
17
16
|
this.allExtendsStack = [[]];
|
|
18
17
|
}
|
|
19
|
-
|
|
18
|
+
|
|
19
|
+
run(root) {
|
|
20
20
|
root = this._visitor.visit(root);
|
|
21
21
|
root.allExtends = this.allExtendsStack[0];
|
|
22
22
|
return root;
|
|
23
|
-
}
|
|
24
|
-
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
visitDeclaration(declNode, visitArgs) {
|
|
25
26
|
visitArgs.visitDeeper = false;
|
|
26
|
-
}
|
|
27
|
-
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
visitMixinDefinition(mixinDefinitionNode, visitArgs) {
|
|
28
30
|
visitArgs.visitDeeper = false;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
visitRuleset(rulesetNode, visitArgs) {
|
|
31
34
|
if (rulesetNode.root) {
|
|
32
35
|
return;
|
|
33
36
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
|
|
38
|
+
let i;
|
|
39
|
+
let j;
|
|
40
|
+
let extend;
|
|
41
|
+
const allSelectorsExtendList = [];
|
|
42
|
+
let extendList;
|
|
43
|
+
|
|
39
44
|
// get &:extend(.a); rules which apply to all selectors in this ruleset
|
|
40
|
-
|
|
45
|
+
const rules = rulesetNode.rules, ruleCnt = rules ? rules.length : 0;
|
|
41
46
|
for (i = 0; i < ruleCnt; i++) {
|
|
42
|
-
if (rulesetNode.rules[i] instanceof
|
|
47
|
+
if (rulesetNode.rules[i] instanceof tree.Extend) {
|
|
43
48
|
allSelectorsExtendList.push(rules[i]);
|
|
44
49
|
rulesetNode.extendOnEveryPath = true;
|
|
45
50
|
}
|
|
46
51
|
}
|
|
52
|
+
|
|
47
53
|
// now find every selector and apply the extends that apply to all extends
|
|
48
54
|
// and the ones which apply to an individual extend
|
|
49
|
-
|
|
55
|
+
const paths = rulesetNode.paths;
|
|
50
56
|
for (i = 0; i < paths.length; i++) {
|
|
51
|
-
|
|
57
|
+
const selectorPath = paths[i], selector = selectorPath[selectorPath.length - 1], selExtendList = selector.extendList;
|
|
58
|
+
|
|
52
59
|
extendList = selExtendList ? utils.copyArray(selExtendList).concat(allSelectorsExtendList)
|
|
53
60
|
: allSelectorsExtendList;
|
|
61
|
+
|
|
54
62
|
if (extendList) {
|
|
55
|
-
extendList = extendList.map(function
|
|
63
|
+
extendList = extendList.map(function(allSelectorsExtend) {
|
|
56
64
|
return allSelectorsExtend.clone();
|
|
57
65
|
});
|
|
58
66
|
}
|
|
67
|
+
|
|
59
68
|
for (j = 0; j < extendList.length; j++) {
|
|
60
69
|
this.foundExtends = true;
|
|
61
70
|
extend = extendList[j];
|
|
62
71
|
extend.findSelfSelectors(selectorPath);
|
|
63
72
|
extend.ruleset = rulesetNode;
|
|
64
|
-
if (j === 0) {
|
|
65
|
-
extend.firstExtendOnThisSelectorPath = true;
|
|
66
|
-
}
|
|
73
|
+
if (j === 0) { extend.firstExtendOnThisSelectorPath = true; }
|
|
67
74
|
this.allExtendsStack[this.allExtendsStack.length - 1].push(extend);
|
|
68
75
|
}
|
|
69
76
|
}
|
|
77
|
+
|
|
70
78
|
this.contexts.push(rulesetNode.selectors);
|
|
71
|
-
}
|
|
72
|
-
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
visitRulesetOut(rulesetNode) {
|
|
73
82
|
if (!rulesetNode.root) {
|
|
74
83
|
this.contexts.length = this.contexts.length - 1;
|
|
75
84
|
}
|
|
76
|
-
}
|
|
77
|
-
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
visitMedia(mediaNode, visitArgs) {
|
|
78
88
|
mediaNode.allExtends = [];
|
|
79
89
|
this.allExtendsStack.push(mediaNode.allExtends);
|
|
80
|
-
}
|
|
81
|
-
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
visitMediaOut(mediaNode) {
|
|
82
93
|
this.allExtendsStack.length = this.allExtendsStack.length - 1;
|
|
83
|
-
}
|
|
84
|
-
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
visitAtRule(atRuleNode, visitArgs) {
|
|
85
97
|
atRuleNode.allExtends = [];
|
|
86
98
|
this.allExtendsStack.push(atRuleNode.allExtends);
|
|
87
|
-
}
|
|
88
|
-
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
visitAtRuleOut(atRuleNode) {
|
|
89
102
|
this.allExtendsStack.length = this.allExtendsStack.length - 1;
|
|
90
|
-
};
|
|
91
|
-
return ExtendFinderVisitor;
|
|
92
|
-
}());
|
|
93
|
-
var ProcessExtendsVisitor = /** @class */ (function () {
|
|
94
|
-
function ProcessExtendsVisitor() {
|
|
95
|
-
this._visitor = new visitor_1.default(this);
|
|
96
103
|
}
|
|
97
|
-
|
|
98
|
-
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
class ProcessExtendsVisitor {
|
|
107
|
+
constructor() {
|
|
108
|
+
this._visitor = new Visitor(this);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
run(root) {
|
|
112
|
+
const extendFinder = new ExtendFinderVisitor();
|
|
99
113
|
this.extendIndices = {};
|
|
100
114
|
extendFinder.run(root);
|
|
101
|
-
if (!extendFinder.foundExtends) {
|
|
102
|
-
return root;
|
|
103
|
-
}
|
|
115
|
+
if (!extendFinder.foundExtends) { return root; }
|
|
104
116
|
root.allExtends = root.allExtends.concat(this.doExtendChaining(root.allExtends, root.allExtends));
|
|
105
117
|
this.allExtendsStack = [root.allExtends];
|
|
106
|
-
|
|
118
|
+
const newRoot = this._visitor.visit(root);
|
|
107
119
|
this.checkExtendsForNonMatched(root.allExtends);
|
|
108
120
|
return newRoot;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
checkExtendsForNonMatched(extendList) {
|
|
124
|
+
const indices = this.extendIndices;
|
|
125
|
+
extendList.filter(function(extend) {
|
|
113
126
|
return !extend.hasFoundMatches && extend.parent_ids.length == 1;
|
|
114
|
-
}).forEach(function
|
|
115
|
-
|
|
127
|
+
}).forEach(function(extend) {
|
|
128
|
+
let selector = '_unknown_';
|
|
116
129
|
try {
|
|
117
130
|
selector = extend.selector.toCSS({});
|
|
118
131
|
}
|
|
119
|
-
catch (_) {
|
|
120
|
-
|
|
121
|
-
|
|
132
|
+
catch (_) {}
|
|
133
|
+
|
|
134
|
+
if (!indices[`${extend.index} ${selector}`]) {
|
|
135
|
+
indices[`${extend.index} ${selector}`] = true;
|
|
122
136
|
/**
|
|
123
137
|
* @todo Shouldn't this be an error? To alert the developer
|
|
124
138
|
* that they may have made an error in the selector they are
|
|
125
139
|
* targeting?
|
|
126
140
|
*/
|
|
127
|
-
|
|
141
|
+
logger.warn(`WARNING: extend '${selector}' has no matches`);
|
|
128
142
|
}
|
|
129
143
|
});
|
|
130
|
-
}
|
|
131
|
-
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
doExtendChaining(extendsList, extendsListTarget, iterationCount) {
|
|
132
147
|
//
|
|
133
148
|
// chaining is different from normal extension.. if we extend an extend then we are not just copying, altering
|
|
134
149
|
// and pasting the selector we would do normally, but we are also adding an extend with the same target selector
|
|
@@ -137,17 +152,21 @@ var ProcessExtendsVisitor = /** @class */ (function () {
|
|
|
137
152
|
// this method deals with all the chaining work - without it, extend is flat and doesn't work on other extend selectors
|
|
138
153
|
// this is also the most expensive.. and a match on one selector can cause an extension of a selector we had already
|
|
139
154
|
// processed if we look at each selector at a time, as is done in visitRuleset
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
155
|
+
|
|
156
|
+
let extendIndex;
|
|
157
|
+
|
|
158
|
+
let targetExtendIndex;
|
|
159
|
+
let matches;
|
|
160
|
+
const extendsToAdd = [];
|
|
161
|
+
let newSelector;
|
|
162
|
+
const extendVisitor = this;
|
|
163
|
+
let selectorPath;
|
|
164
|
+
let extend;
|
|
165
|
+
let targetExtend;
|
|
166
|
+
let newExtend;
|
|
167
|
+
|
|
150
168
|
iterationCount = iterationCount || 0;
|
|
169
|
+
|
|
151
170
|
// loop through comparing every extend with every target extend.
|
|
152
171
|
// a target extend is the one on the ruleset we are looking at copy/edit/pasting in place
|
|
153
172
|
// e.g. .a:extend(.b) {} and .b:extend(.c) {} then the first extend extends the second one
|
|
@@ -156,32 +175,41 @@ var ProcessExtendsVisitor = /** @class */ (function () {
|
|
|
156
175
|
// case when processing media queries
|
|
157
176
|
for (extendIndex = 0; extendIndex < extendsList.length; extendIndex++) {
|
|
158
177
|
for (targetExtendIndex = 0; targetExtendIndex < extendsListTarget.length; targetExtendIndex++) {
|
|
178
|
+
|
|
159
179
|
extend = extendsList[extendIndex];
|
|
160
180
|
targetExtend = extendsListTarget[targetExtendIndex];
|
|
181
|
+
|
|
161
182
|
// look for circular references
|
|
162
|
-
if (extend.parent_ids.indexOf(targetExtend.object_id) >= 0) {
|
|
163
|
-
|
|
164
|
-
}
|
|
183
|
+
if ( extend.parent_ids.indexOf( targetExtend.object_id ) >= 0 ) { continue; }
|
|
184
|
+
|
|
165
185
|
// find a match in the target extends self selector (the bit before :extend)
|
|
166
186
|
selectorPath = [targetExtend.selfSelectors[0]];
|
|
167
187
|
matches = extendVisitor.findMatch(extend, selectorPath);
|
|
188
|
+
|
|
168
189
|
if (matches.length) {
|
|
169
190
|
extend.hasFoundMatches = true;
|
|
191
|
+
|
|
170
192
|
// we found a match, so for each self selector..
|
|
171
|
-
extend.selfSelectors.forEach(function
|
|
172
|
-
|
|
193
|
+
extend.selfSelectors.forEach(function(selfSelector) {
|
|
194
|
+
const info = targetExtend.visibilityInfo();
|
|
195
|
+
|
|
173
196
|
// process the extend as usual
|
|
174
197
|
newSelector = extendVisitor.extendSelector(matches, selectorPath, selfSelector, extend.isVisible());
|
|
198
|
+
|
|
175
199
|
// but now we create a new extend from it
|
|
176
|
-
newExtend = new
|
|
200
|
+
newExtend = new(tree.Extend)(targetExtend.selector, targetExtend.option, 0, targetExtend.fileInfo(), info);
|
|
177
201
|
newExtend.selfSelectors = newSelector;
|
|
202
|
+
|
|
178
203
|
// add the extend onto the list of extends for that selector
|
|
179
204
|
newSelector[newSelector.length - 1].extendList = [newExtend];
|
|
205
|
+
|
|
180
206
|
// record that we need to add it.
|
|
181
207
|
extendsToAdd.push(newExtend);
|
|
182
208
|
newExtend.ruleset = targetExtend.ruleset;
|
|
209
|
+
|
|
183
210
|
// remember its parents for circular references
|
|
184
211
|
newExtend.parent_ids = newExtend.parent_ids.concat(targetExtend.parent_ids, extend.parent_ids);
|
|
212
|
+
|
|
185
213
|
// only process the selector once.. if we have :extend(.a,.b) then multiple
|
|
186
214
|
// extends will look at the same selector path, so when extending
|
|
187
215
|
// we know that any others will be duplicates in terms of what is added to the css
|
|
@@ -193,101 +221,114 @@ var ProcessExtendsVisitor = /** @class */ (function () {
|
|
|
193
221
|
}
|
|
194
222
|
}
|
|
195
223
|
}
|
|
224
|
+
|
|
196
225
|
if (extendsToAdd.length) {
|
|
197
226
|
// try to detect circular references to stop a stack overflow.
|
|
198
227
|
// may no longer be needed.
|
|
199
228
|
this.extendChainCount++;
|
|
200
229
|
if (iterationCount > 100) {
|
|
201
|
-
|
|
202
|
-
|
|
230
|
+
let selectorOne = '{unable to calculate}';
|
|
231
|
+
let selectorTwo = '{unable to calculate}';
|
|
203
232
|
try {
|
|
204
233
|
selectorOne = extendsToAdd[0].selfSelectors[0].toCSS();
|
|
205
234
|
selectorTwo = extendsToAdd[0].selector.toCSS();
|
|
206
235
|
}
|
|
207
|
-
catch (e) {
|
|
208
|
-
throw { message:
|
|
236
|
+
catch (e) {}
|
|
237
|
+
throw { message: `extend circular reference detected. One of the circular extends is currently:${selectorOne}:extend(${selectorTwo})`};
|
|
209
238
|
}
|
|
239
|
+
|
|
210
240
|
// now process the new extends on the existing rules so that we can handle a extending b extending c extending
|
|
211
241
|
// d extending e...
|
|
212
242
|
return extendsToAdd.concat(extendVisitor.doExtendChaining(extendsToAdd, extendsListTarget, iterationCount + 1));
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
243
|
+
} else {
|
|
215
244
|
return extendsToAdd;
|
|
216
245
|
}
|
|
217
|
-
}
|
|
218
|
-
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
visitDeclaration(ruleNode, visitArgs) {
|
|
219
249
|
visitArgs.visitDeeper = false;
|
|
220
|
-
}
|
|
221
|
-
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
visitMixinDefinition(mixinDefinitionNode, visitArgs) {
|
|
222
253
|
visitArgs.visitDeeper = false;
|
|
223
|
-
}
|
|
224
|
-
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
visitSelector(selectorNode, visitArgs) {
|
|
225
257
|
visitArgs.visitDeeper = false;
|
|
226
|
-
}
|
|
227
|
-
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
visitRuleset(rulesetNode, visitArgs) {
|
|
228
261
|
if (rulesetNode.root) {
|
|
229
262
|
return;
|
|
230
263
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
var selectorPath;
|
|
264
|
+
let matches;
|
|
265
|
+
const allExtends = this.allExtendsStack[this.allExtendsStack.length - 1];
|
|
266
|
+
const selectorsToAdd = [];
|
|
267
|
+
const paths = rulesetNode.paths;
|
|
268
|
+
const pathCount = paths.length;
|
|
269
|
+
|
|
238
270
|
// look at each selector path in the ruleset, find any extend matches and then copy, find and replace
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
271
|
+
|
|
272
|
+
for (let extendIndex = 0; extendIndex < allExtends.length; extendIndex++) {
|
|
273
|
+
const extend = allExtends[extendIndex];
|
|
274
|
+
for (let pathIndex = 0; pathIndex < pathCount; pathIndex++) {
|
|
275
|
+
const selectorPath = paths[pathIndex];
|
|
276
|
+
|
|
242
277
|
// extending extends happens initially, before the main pass
|
|
243
|
-
if (rulesetNode.extendOnEveryPath) {
|
|
244
|
-
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
}
|
|
250
|
-
matches = this.findMatch(allExtends[extendIndex], selectorPath);
|
|
278
|
+
if (rulesetNode.extendOnEveryPath) { continue; }
|
|
279
|
+
const extendList = selectorPath[selectorPath.length - 1].extendList;
|
|
280
|
+
if (extendList && extendList.length) { continue; }
|
|
281
|
+
|
|
282
|
+
matches = this.findMatch(extend, selectorPath);
|
|
283
|
+
|
|
251
284
|
if (matches.length) {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
285
|
+
extend.hasFoundMatches = true;
|
|
286
|
+
|
|
287
|
+
const selfSelectors = extend.selfSelectors;
|
|
288
|
+
const isVisible = extend.isVisible();
|
|
289
|
+
for (let si = 0; si < selfSelectors.length; si++) {
|
|
290
|
+
selectorsToAdd.push(this.extendSelector(matches, selectorPath, selfSelectors[si], isVisible));
|
|
291
|
+
}
|
|
258
292
|
}
|
|
259
293
|
}
|
|
260
294
|
}
|
|
261
|
-
rulesetNode.paths =
|
|
262
|
-
}
|
|
263
|
-
|
|
295
|
+
rulesetNode.paths = paths.concat(selectorsToAdd);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
findMatch(extend, haystackSelectorPath) {
|
|
264
299
|
//
|
|
265
300
|
// look through the haystack selector path to try and find the needle - extend.selector
|
|
266
301
|
// returns an array of selector matches that can then be replaced
|
|
267
302
|
//
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
303
|
+
let haystackSelectorIndex;
|
|
304
|
+
|
|
305
|
+
let hackstackSelector;
|
|
306
|
+
let hackstackElementIndex;
|
|
307
|
+
let haystackElement;
|
|
308
|
+
let targetCombinator;
|
|
309
|
+
let i;
|
|
310
|
+
const needleElements = extend.selector.elements;
|
|
311
|
+
const potentialMatches = [];
|
|
312
|
+
let potentialMatch;
|
|
313
|
+
const matches = [];
|
|
314
|
+
|
|
279
315
|
// loop through the haystack elements
|
|
280
316
|
for (haystackSelectorIndex = 0; haystackSelectorIndex < haystackSelectorPath.length; haystackSelectorIndex++) {
|
|
281
317
|
hackstackSelector = haystackSelectorPath[haystackSelectorIndex];
|
|
318
|
+
|
|
282
319
|
for (hackstackElementIndex = 0; hackstackElementIndex < hackstackSelector.elements.length; hackstackElementIndex++) {
|
|
320
|
+
|
|
283
321
|
haystackElement = hackstackSelector.elements[hackstackElementIndex];
|
|
322
|
+
|
|
284
323
|
// if we allow elements before our match we can add a potential match every time. otherwise only at the first element.
|
|
285
324
|
if (extend.allowBefore || (haystackSelectorIndex === 0 && hackstackElementIndex === 0)) {
|
|
286
|
-
potentialMatches.push({
|
|
287
|
-
initialCombinator: haystackElement.combinator
|
|
325
|
+
potentialMatches.push({pathIndex: haystackSelectorIndex, index: hackstackElementIndex, matched: 0,
|
|
326
|
+
initialCombinator: haystackElement.combinator});
|
|
288
327
|
}
|
|
328
|
+
|
|
289
329
|
for (i = 0; i < potentialMatches.length; i++) {
|
|
290
330
|
potentialMatch = potentialMatches[i];
|
|
331
|
+
|
|
291
332
|
// selectors add " " onto the first element. When we use & it joins the selectors together, but if we don't
|
|
292
333
|
// then each selector in haystackSelectorPath has a space before it added in the toCSS phase. so we need to
|
|
293
334
|
// work out what the resulting combinator will be
|
|
@@ -295,14 +336,15 @@ var ProcessExtendsVisitor = /** @class */ (function () {
|
|
|
295
336
|
if (targetCombinator === '' && hackstackElementIndex === 0) {
|
|
296
337
|
targetCombinator = ' ';
|
|
297
338
|
}
|
|
339
|
+
|
|
298
340
|
// if we don't match, null our match to indicate failure
|
|
299
|
-
if (!
|
|
341
|
+
if (!this.isElementValuesEqual(needleElements[potentialMatch.matched].value, haystackElement.value) ||
|
|
300
342
|
(potentialMatch.matched > 0 && needleElements[potentialMatch.matched].combinator.value !== targetCombinator)) {
|
|
301
343
|
potentialMatch = null;
|
|
302
|
-
}
|
|
303
|
-
else {
|
|
344
|
+
} else {
|
|
304
345
|
potentialMatch.matched++;
|
|
305
346
|
}
|
|
347
|
+
|
|
306
348
|
// if we are still valid and have finished, test whether we have elements after and whether these are allowed
|
|
307
349
|
if (potentialMatch) {
|
|
308
350
|
potentialMatch.finished = potentialMatch.matched === needleElements.length;
|
|
@@ -321,8 +363,7 @@ var ProcessExtendsVisitor = /** @class */ (function () {
|
|
|
321
363
|
potentialMatches.length = 0; // we don't allow matches to overlap, so start matching again
|
|
322
364
|
matches.push(potentialMatch);
|
|
323
365
|
}
|
|
324
|
-
}
|
|
325
|
-
else {
|
|
366
|
+
} else {
|
|
326
367
|
potentialMatches.splice(i, 1);
|
|
327
368
|
i--;
|
|
328
369
|
}
|
|
@@ -330,12 +371,13 @@ var ProcessExtendsVisitor = /** @class */ (function () {
|
|
|
330
371
|
}
|
|
331
372
|
}
|
|
332
373
|
return matches;
|
|
333
|
-
}
|
|
334
|
-
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
isElementValuesEqual(elementValue1, elementValue2) {
|
|
335
377
|
if (typeof elementValue1 === 'string' || typeof elementValue2 === 'string') {
|
|
336
378
|
return elementValue1 === elementValue2;
|
|
337
379
|
}
|
|
338
|
-
if (elementValue1 instanceof
|
|
380
|
+
if (elementValue1 instanceof tree.Attribute) {
|
|
339
381
|
if (elementValue1.op !== elementValue2.op || elementValue1.key !== elementValue2.key) {
|
|
340
382
|
return false;
|
|
341
383
|
}
|
|
@@ -351,11 +393,11 @@ var ProcessExtendsVisitor = /** @class */ (function () {
|
|
|
351
393
|
}
|
|
352
394
|
elementValue1 = elementValue1.value;
|
|
353
395
|
elementValue2 = elementValue2.value;
|
|
354
|
-
if (elementValue1 instanceof
|
|
355
|
-
if (!(elementValue2 instanceof
|
|
396
|
+
if (elementValue1 instanceof tree.Selector) {
|
|
397
|
+
if (!(elementValue2 instanceof tree.Selector) || elementValue1.elements.length !== elementValue2.elements.length) {
|
|
356
398
|
return false;
|
|
357
399
|
}
|
|
358
|
-
for (
|
|
400
|
+
for (let i = 0; i < elementValue1.elements.length; i++) {
|
|
359
401
|
if (elementValue1.elements[i].combinator.value !== elementValue2.elements[i].combinator.value) {
|
|
360
402
|
if (i !== 0 || (elementValue1.elements[i].combinator.value || ' ') !== (elementValue2.elements[i].combinator.value || ' ')) {
|
|
361
403
|
return false;
|
|
@@ -368,31 +410,46 @@ var ProcessExtendsVisitor = /** @class */ (function () {
|
|
|
368
410
|
return true;
|
|
369
411
|
}
|
|
370
412
|
return false;
|
|
371
|
-
}
|
|
372
|
-
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
extendSelector(matches, selectorPath, replacementSelector, isVisible) {
|
|
416
|
+
|
|
373
417
|
// for a set of matches, replace each match with the replacement selector
|
|
374
|
-
|
|
418
|
+
|
|
419
|
+
let currentSelectorPathIndex = 0, currentSelectorPathElementIndex = 0, path = [], matchIndex, selector, firstElement, match, newElements;
|
|
420
|
+
|
|
375
421
|
for (matchIndex = 0; matchIndex < matches.length; matchIndex++) {
|
|
376
422
|
match = matches[matchIndex];
|
|
377
423
|
selector = selectorPath[match.pathIndex];
|
|
378
|
-
firstElement = new
|
|
424
|
+
firstElement = new tree.Element(
|
|
425
|
+
match.initialCombinator,
|
|
426
|
+
replacementSelector.elements[0].value,
|
|
427
|
+
replacementSelector.elements[0].isVariable,
|
|
428
|
+
replacementSelector.elements[0].getIndex(),
|
|
429
|
+
replacementSelector.elements[0].fileInfo()
|
|
430
|
+
);
|
|
431
|
+
|
|
379
432
|
if (match.pathIndex > currentSelectorPathIndex && currentSelectorPathElementIndex > 0) {
|
|
380
433
|
path[path.length - 1].elements = path[path.length - 1]
|
|
381
434
|
.elements.concat(selectorPath[currentSelectorPathIndex].elements.slice(currentSelectorPathElementIndex));
|
|
382
435
|
currentSelectorPathElementIndex = 0;
|
|
383
436
|
currentSelectorPathIndex++;
|
|
384
437
|
}
|
|
438
|
+
|
|
385
439
|
newElements = selector.elements
|
|
386
440
|
.slice(currentSelectorPathElementIndex, match.index)
|
|
387
441
|
.concat([firstElement])
|
|
388
442
|
.concat(replacementSelector.elements.slice(1));
|
|
443
|
+
|
|
389
444
|
if (currentSelectorPathIndex === match.pathIndex && matchIndex > 0) {
|
|
390
445
|
path[path.length - 1].elements =
|
|
391
446
|
path[path.length - 1].elements.concat(newElements);
|
|
392
|
-
}
|
|
393
|
-
else {
|
|
447
|
+
} else {
|
|
394
448
|
path = path.concat(selectorPath.slice(currentSelectorPathIndex, match.pathIndex));
|
|
395
|
-
|
|
449
|
+
|
|
450
|
+
path.push(new tree.Selector(
|
|
451
|
+
newElements
|
|
452
|
+
));
|
|
396
453
|
}
|
|
397
454
|
currentSelectorPathIndex = match.endPathIndex;
|
|
398
455
|
currentSelectorPathElementIndex = match.endPathElementIndex;
|
|
@@ -401,44 +458,48 @@ var ProcessExtendsVisitor = /** @class */ (function () {
|
|
|
401
458
|
currentSelectorPathIndex++;
|
|
402
459
|
}
|
|
403
460
|
}
|
|
461
|
+
|
|
404
462
|
if (currentSelectorPathIndex < selectorPath.length && currentSelectorPathElementIndex > 0) {
|
|
405
463
|
path[path.length - 1].elements = path[path.length - 1]
|
|
406
464
|
.elements.concat(selectorPath[currentSelectorPathIndex].elements.slice(currentSelectorPathElementIndex));
|
|
407
465
|
currentSelectorPathIndex++;
|
|
408
466
|
}
|
|
467
|
+
|
|
409
468
|
path = path.concat(selectorPath.slice(currentSelectorPathIndex, selectorPath.length));
|
|
410
469
|
path = path.map(function (currentValue) {
|
|
411
470
|
// we can re-use elements here, because the visibility property matters only for selectors
|
|
412
|
-
|
|
471
|
+
const derived = currentValue.createDerived(currentValue.elements);
|
|
413
472
|
if (isVisible) {
|
|
414
473
|
derived.ensureVisibility();
|
|
415
|
-
}
|
|
416
|
-
else {
|
|
474
|
+
} else {
|
|
417
475
|
derived.ensureInvisibility();
|
|
418
476
|
}
|
|
419
477
|
return derived;
|
|
420
478
|
});
|
|
421
479
|
return path;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
visitMedia(mediaNode, visitArgs) {
|
|
483
|
+
let newAllExtends = mediaNode.allExtends.concat(this.allExtendsStack[this.allExtendsStack.length - 1]);
|
|
425
484
|
newAllExtends = newAllExtends.concat(this.doExtendChaining(newAllExtends, mediaNode.allExtends));
|
|
426
485
|
this.allExtendsStack.push(newAllExtends);
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
visitMediaOut(mediaNode) {
|
|
489
|
+
const lastIndex = this.allExtendsStack.length - 1;
|
|
430
490
|
this.allExtendsStack.length = lastIndex;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
visitAtRule(atRuleNode, visitArgs) {
|
|
494
|
+
let newAllExtends = atRuleNode.allExtends.concat(this.allExtendsStack[this.allExtendsStack.length - 1]);
|
|
434
495
|
newAllExtends = newAllExtends.concat(this.doExtendChaining(newAllExtends, atRuleNode.allExtends));
|
|
435
496
|
this.allExtendsStack.push(newAllExtends);
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
visitAtRuleOut(atRuleNode) {
|
|
500
|
+
const lastIndex = this.allExtendsStack.length - 1;
|
|
439
501
|
this.allExtendsStack.length = lastIndex;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
//# sourceMappingURL=extend-visitor.js.map
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
export default ProcessExtendsVisitor;
|