(node, item, list)
| 8 | } from './utils.js'; |
| 9 | |
| 10 | function processRule(node, item, list) { |
| 11 | const selectors = node.prelude.children; |
| 12 | const declarations = node.block.children; |
| 13 | |
| 14 | list.prevUntil(item.prev, function(prev) { |
| 15 | // skip non-ruleset node if safe |
| 16 | if (prev.type !== 'Rule') { |
| 17 | return unsafeToSkipNode.call(selectors, prev); |
| 18 | } |
| 19 | |
| 20 | const prevSelectors = prev.prelude.children; |
| 21 | const prevDeclarations = prev.block.children; |
| 22 | |
| 23 | // try to join rulesets with equal pseudo signature |
| 24 | if (node.pseudoSignature === prev.pseudoSignature) { |
| 25 | // try to join by selectors |
| 26 | if (isEqualSelectors(prevSelectors, selectors)) { |
| 27 | prevDeclarations.appendList(declarations); |
| 28 | list.remove(item); |
| 29 | return true; |
| 30 | } |
| 31 | |
| 32 | // try to join by declarations |
| 33 | if (isEqualDeclarations(declarations, prevDeclarations)) { |
| 34 | addSelectors(prevSelectors, selectors); |
| 35 | list.remove(item); |
| 36 | return true; |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | // go to prev ruleset if has no selector similarities |
| 41 | return hasSimilarSelectors(selectors, prevSelectors); |
| 42 | }); |
| 43 | } |
| 44 | |
| 45 | // NOTE: direction should be left to right, since rulesets merge to left |
| 46 | // ruleset. When direction right to left unmerged rulesets may prevent lookup |
nothing calls this directly
no test coverage detected
searching dependent graphs…