Blame view

node_modules/postcss/lib/document.js 654 Bytes
7820380e   “wangming”   1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
  'use strict'
  
  let Container = require('./container')
  
  let LazyResult, Processor
  
  class Document extends Container {
    constructor(defaults) {
      // type needs to be passed to super, otherwise child roots won't be normalized correctly
      super({ type: 'document', ...defaults })
  
      if (!this.nodes) {
        this.nodes = []
      }
    }
  
    toResult(opts = {}) {
      let lazy = new LazyResult(new Processor(), this, opts)
  
      return lazy.stringify()
    }
  }
  
  Document.registerLazyResult = dependant => {
    LazyResult = dependant
  }
  
  Document.registerProcessor = dependant => {
    Processor = dependant
  }
  
  module.exports = Document
  Document.default = Document