Last change
on this file since 8d391a1 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.6 KB
|
Line | |
---|
1 | var resolveKeyword = require('css-tree').keyword;
|
---|
2 | var walk = require('css-tree').walk;
|
---|
3 | var generate = require('css-tree').generate;
|
---|
4 | var createDeclarationIndexer = require('./createDeclarationIndexer');
|
---|
5 | var processSelector = require('./processSelector');
|
---|
6 |
|
---|
7 | module.exports = function prepare(ast, options) {
|
---|
8 | var markDeclaration = createDeclarationIndexer();
|
---|
9 |
|
---|
10 | walk(ast, {
|
---|
11 | visit: 'Rule',
|
---|
12 | enter: function processRule(node) {
|
---|
13 | node.block.children.each(markDeclaration);
|
---|
14 | processSelector(node, options.usage);
|
---|
15 | }
|
---|
16 | });
|
---|
17 |
|
---|
18 | walk(ast, {
|
---|
19 | visit: 'Atrule',
|
---|
20 | enter: function(node) {
|
---|
21 | if (node.prelude) {
|
---|
22 | node.prelude.id = null; // pre-init property to avoid multiple hidden class for generate
|
---|
23 | node.prelude.id = generate(node.prelude);
|
---|
24 | }
|
---|
25 |
|
---|
26 | // compare keyframe selectors by its values
|
---|
27 | // NOTE: still no clarification about problems with keyframes selector grouping (issue #197)
|
---|
28 | if (resolveKeyword(node.name).basename === 'keyframes') {
|
---|
29 | node.block.avoidRulesMerge = true; /* probably we don't need to prevent those merges for @keyframes
|
---|
30 | TODO: need to be checked */
|
---|
31 | node.block.children.each(function(rule) {
|
---|
32 | rule.prelude.children.each(function(simpleselector) {
|
---|
33 | simpleselector.compareMarker = simpleselector.id;
|
---|
34 | });
|
---|
35 | });
|
---|
36 | }
|
---|
37 | }
|
---|
38 | });
|
---|
39 |
|
---|
40 | return {
|
---|
41 | declaration: markDeclaration
|
---|
42 | };
|
---|
43 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.