source: trip-planner-front/node_modules/postcss/lib/root.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.2 KB
Line 
1'use strict'
2
3let Container = require('./container')
4
5let LazyResult, Processor
6
7class Root extends Container {
8 constructor(defaults) {
9 super(defaults)
10 this.type = 'root'
11 if (!this.nodes) this.nodes = []
12 }
13
14 removeChild(child, ignore) {
15 let index = this.index(child)
16
17 if (!ignore && index === 0 && this.nodes.length > 1) {
18 this.nodes[1].raws.before = this.nodes[index].raws.before
19 }
20
21 return super.removeChild(child)
22 }
23
24 normalize(child, sample, type) {
25 let nodes = super.normalize(child)
26
27 if (sample) {
28 if (type === 'prepend') {
29 if (this.nodes.length > 1) {
30 sample.raws.before = this.nodes[1].raws.before
31 } else {
32 delete sample.raws.before
33 }
34 } else if (this.first !== sample) {
35 for (let node of nodes) {
36 node.raws.before = sample.raws.before
37 }
38 }
39 }
40
41 return nodes
42 }
43
44 toResult(opts = {}) {
45 let lazy = new LazyResult(new Processor(), this, opts)
46 return lazy.stringify()
47 }
48}
49
50Root.registerLazyResult = dependant => {
51 LazyResult = dependant
52}
53
54Root.registerProcessor = dependant => {
55 Processor = dependant
56}
57
58module.exports = Root
59Root.default = Root
Note: See TracBrowser for help on using the repository browser.