MCPcopy
hub / github.com/postcss/postcss / constructor

Method constructor

lib/node.js:67–89  ·  view source on GitHub ↗
(defaults = {})

Source from the content-addressed store, hash-verified

65 }
66
67 constructor(defaults = {}) {
68 this.raws = {}
69 this[isClean] = false
70 this[my] = true
71
72 for (let name in defaults) {
73 if (name === 'nodes') {
74 this.nodes = []
75 for (let node of defaults[name]) {
76 // Clone only nodes that already belong to another tree, so passing a
77 // freshly created (parent-less) node adopts that instance instead of
78 // a copy and keeps the caller's reference usable. See #1987.
79 if (typeof node.clone === 'function' && node.parent) {
80 this.append(node.clone())
81 } else {
82 this.append(node)
83 }
84 }
85 } else {
86 this[name] = defaults[name]
87 }
88 }
89 }
90
91 addToError(error) {
92 error.postcssNode = this

Callers

nothing calls this directly

Calls 2

cloneMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected