@alexgyver/component 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Component.js CHANGED
@@ -167,31 +167,14 @@ export class Sheet {
167
167
  if (typeof id === 'object') id = id.constructor.name;
168
168
 
169
169
  if (!Sheet.#int.has(id) && !Sheet.#ext.has(id)) {
170
- // if (typeof style === 'object') {
171
- // let str = '';
172
- // let f = 0;
173
- // for (const v of style) {
174
- // if (f = !f) {
175
- // str += v;
176
- // } else {
177
- // str += '{';
178
- // for (const rule of v) str += rule + ';';
179
- // str += '}';
180
- // }
181
- // }
182
- // style = str;
183
- // }
184
-
185
170
  if (ext) {
186
171
  let sheet = document.createElement('style');
187
172
  document.head.appendChild(sheet);
188
- sheet.sheet.insertRule(style);
173
+ sheet.textContent = style;
189
174
  Sheet.#ext.set(id, sheet);
190
175
  } else {
191
- if (!Sheet.#sheet) {
192
- Sheet.#sheet = document.head.appendChild(document.createElement('style')).sheet;
193
- }
194
- Sheet.#sheet.insertRule(style);
176
+ if (!Sheet.#sheet) Sheet.#sheet = document.head.appendChild(document.createElement('style'));
177
+ Sheet.#sheet.textContent += style + '\r\n';
195
178
  Sheet.#int.add(id);
196
179
  }
197
180
  }
package/example/script.js CHANGED
@@ -16,7 +16,15 @@ class Button extends Component {
16
16
  }
17
17
  });
18
18
 
19
- Sheet.addStyle('.btn {background: red;color: white}', this, true); // this превратится в Button
19
+ Sheet.addStyle(`
20
+ .btn {
21
+ background: red;
22
+ }
23
+ .btn {
24
+ color: white
25
+ }
26
+ `,
27
+ this, true); // this превратится в Button
20
28
  }
21
29
  }
22
30
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexgyver/component",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Simple HTML element builder",
5
5
  "main": "./Component.js",
6
6
  "module": "./Component.js",