-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdocument.js
More file actions
41 lines (36 loc) · 741 Bytes
/
document.js
File metadata and controls
41 lines (36 loc) · 741 Bytes
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
34
35
36
37
38
39
40
41
"use strict";
const PostCssRoot = require("postcss/lib/root");
class Document extends PostCssRoot {
toString (stringifier) {
return super.toString(stringifier || {
stringify: require("./stringify"),
});
}
each (callback) {
const result = this.nodes.map(node => node.each(callback));
return result.every(result => result !== false) && result.pop();
}
append () {
this.last.append.apply(
this.last,
Array.from(arguments)
);
return this;
}
prepend () {
this.first.prepend.apply(
this.first,
Array.from(arguments)
);
return this;
}
insertBefore (exist, add) {
exist.prepend(add);
return this;
}
insertAfter (exist, add) {
exist.append(add);
return this;
}
}
module.exports = Document;