chore: format

This commit is contained in:
Ayo 2023-11-26 04:19:19 +01:00
parent da85a71aec
commit 9480f37844

View file

@ -94,7 +94,7 @@ export class WebComponent extends HTMLElement {
this[property] = currentValue === "" || currentValue; this[property] = currentValue === "" || currentValue;
this[camelCaps] = this[property]; // remove on v2 this[camelCaps] = this[property]; // remove on v2
this.#handleUpdateProp(camelCaps, currentValue) this.#handleUpdateProp(camelCaps, currentValue);
this.render(); this.render();
this.onChanges({ property, previousValue, currentValue }); this.onChanges({ property, previousValue, currentValue });
@ -102,11 +102,9 @@ export class WebComponent extends HTMLElement {
} }
#handleUpdateProp(key, value) { #handleUpdateProp(key, value) {
const restored = this.#restoreType(value, this.#typeMap[key]);
const restored = this.#restoreType(value, this.#typeMap[key]) if (restored !== this.props[key]) this.props[key] = value;
if (restored !== this.props[key])
this.props[key] = value;
} }
#getCamelCaps(kebab) { #getCamelCaps(kebab) {
@ -115,17 +113,17 @@ export class WebComponent extends HTMLElement {
#typeMap = {}; #typeMap = {};
#restoreType = (value, type) => { #restoreType = (value, type) => {
switch (type) { switch (type) {
case "string": case "string":
return value; return value;
case "number": case "number":
case "boolean": case "boolean":
return JSON.parse(value); return JSON.parse(value);
default: default:
return value; return value;
} }
}; };
#handler(setter, typeMap) { #handler(setter, typeMap) {
const getKebab = (str) => { const getKebab = (str) => {
@ -135,7 +133,6 @@ export class WebComponent extends HTMLElement {
); );
}; };
return { return {
set(obj, prop, value) { set(obj, prop, value) {
const oldValue = obj[prop]; const oldValue = obj[prop];
@ -151,7 +148,7 @@ export class WebComponent extends HTMLElement {
} }
return true; return true;
} },
}; };
} }