1 |
|
2 | const STYLE = document.createElement('style');
|
3 | const SHEET = STYLE.sheet;
|
4 |
|
5 | STYLE.setAttribute('title', 'oxe');
|
6 | STYLE.setAttribute('type', 'text/css');
|
7 |
|
8 | export default {
|
9 |
|
10 | get style () { return STYLE; },
|
11 | get sheet () { return SHEET; },
|
12 |
|
13 | add (data) {
|
14 | this.sheet.insertRule(data);
|
15 | },
|
16 |
|
17 | append (data) {
|
18 | this.style.appendChild(document.createTextNode(data));
|
19 | },
|
20 |
|
21 | async setup (option) {
|
22 | option = option || {};
|
23 |
|
24 | if (option.style) {
|
25 | this.append(option.style);
|
26 | }
|
27 |
|
28 | document.head.appendChild(this.style);
|
29 | }
|
30 |
|
31 | };
|