@alexgyver/component 1.1.0 → 1.1.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 +6 -0
- package/package.json +1 -1
package/Component.js
CHANGED
|
@@ -80,6 +80,10 @@ export class Component {
|
|
|
80
80
|
* @returns {Node}
|
|
81
81
|
*/
|
|
82
82
|
static config(el, data, ns = false) {
|
|
83
|
+
if (Array.isArray(el)) {
|
|
84
|
+
el.forEach(e => Component.config(e, data, ns));
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
83
87
|
if (!(el instanceof Node) || (typeof data !== 'object')) return el;
|
|
84
88
|
const context = data.context;
|
|
85
89
|
|
|
@@ -112,7 +116,9 @@ export class Component {
|
|
|
112
116
|
case 'parent': if (val instanceof Node || val instanceof DocumentFragment) val.append(el); break;
|
|
113
117
|
case 'attrs': for (let attr in val) el.setAttribute(attr, val[attr]); break;
|
|
114
118
|
case 'props': for (let prop in val) el[prop] = val[prop]; break;
|
|
119
|
+
case 'child_r': el.replaceChildren();
|
|
115
120
|
case 'child': addChild(val); break;
|
|
121
|
+
case 'children_r': el.replaceChildren();
|
|
116
122
|
case 'children': for (const obj of val) addChild(obj); break;
|
|
117
123
|
case 'style':
|
|
118
124
|
if (typeof val === 'string') el.style.cssText += (val + ';');
|