@fruit-ui/core 1.3.0 → 1.3.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/README.md +1 -3
- package/package.json +1 -1
- package/src/index.js +9 -4
package/README.md
CHANGED
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -196,8 +196,10 @@ function createElementFromTemplate(template, onMounts, producer = null) {
|
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
for (const attribute in rest) {
|
|
199
|
-
if (
|
|
200
|
-
|
|
199
|
+
if (template[attribute] === undefined)
|
|
200
|
+
element.removeAttribute(attribute);
|
|
201
|
+
else
|
|
202
|
+
element.setAttribute(attribute, template[attribute]);
|
|
201
203
|
}
|
|
202
204
|
if (template.dataset) {
|
|
203
205
|
for (const k in template.dataset) {
|
|
@@ -292,7 +294,7 @@ function createElementFromElementable(elementable, onMounts) {
|
|
|
292
294
|
function createElementFromComponent(component, onMounts) {
|
|
293
295
|
const boundProducer = bindTemplateProducer(component.render, component);
|
|
294
296
|
thisRecord[boundProducer.componentId] = boundProducer.this;
|
|
295
|
-
boundProducer.this.state = component.state ? component.state.call(boundProducer.this) : {};
|
|
297
|
+
boundProducer.this.state = typeof component.state === 'function' ? component.state.call(boundProducer.this) : component.state ?? {};
|
|
296
298
|
const template = boundProducer();
|
|
297
299
|
return createElementFromTemplate.call(boundProducer.this, giveTemplateComponentMetadata(template, boundProducer.componentId, component.key, component.binding), onMounts, boundProducer);
|
|
298
300
|
}
|
|
@@ -444,7 +446,10 @@ function rerenderElementFromTemplate(element, template, onMounts) {
|
|
|
444
446
|
}
|
|
445
447
|
const {tag, class: c, style, on, componentId, children, cloneFrom, dataset, key, binding, innerHTML, xmlns, ...rest} = template;
|
|
446
448
|
for (const attribute in rest) {
|
|
447
|
-
|
|
449
|
+
if (template[attribute] === undefined)
|
|
450
|
+
element.removeAttribute(attribute);
|
|
451
|
+
else
|
|
452
|
+
element.setAttribute(attribute, template[attribute]);
|
|
448
453
|
}
|
|
449
454
|
if (template.innerHTML) {
|
|
450
455
|
element.innerHTML = template.innerHTML;
|