@alexgyver/component 1.2.0 → 1.2.2
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 +4 -21
- package/example/script.js +9 -1
- package/package.json +1 -1
package/Component.js
CHANGED
|
@@ -81,7 +81,7 @@ export class Component {
|
|
|
81
81
|
case 'context':
|
|
82
82
|
case 'svg':
|
|
83
83
|
continue;
|
|
84
|
-
case 'text': el.textContent = val; break;
|
|
84
|
+
case 'text': el.textContent = val + ''; break;
|
|
85
85
|
case 'html': el.innerHTML = val; break;
|
|
86
86
|
case 'class': el.classList.add(...val.split(' ')); break;
|
|
87
87
|
case 'also': if (context) val.call(context, el); break;
|
|
@@ -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.
|
|
173
|
+
sheet.textContent = style;
|
|
189
174
|
Sheet.#ext.set(id, sheet);
|
|
190
175
|
} else {
|
|
191
|
-
if (!Sheet.#sheet)
|
|
192
|
-
|
|
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(
|
|
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
|
|