From 9480f378442ee6b2dbc6942bdfb6d59755a1deaf Mon Sep 17 00:00:00 2001 From: Ayo Date: Sun, 26 Nov 2023 04:19:19 +0100 Subject: [PATCH] chore: format --- src/WebComponent.js | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/WebComponent.js b/src/WebComponent.js index 7486fcc..32dd0ef 100644 --- a/src/WebComponent.js +++ b/src/WebComponent.js @@ -94,7 +94,7 @@ export class WebComponent extends HTMLElement { this[property] = currentValue === "" || currentValue; this[camelCaps] = this[property]; // remove on v2 - this.#handleUpdateProp(camelCaps, currentValue) + this.#handleUpdateProp(camelCaps, currentValue); this.render(); this.onChanges({ property, previousValue, currentValue }); @@ -102,11 +102,9 @@ export class WebComponent extends HTMLElement { } #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) { @@ -115,17 +113,17 @@ export class WebComponent extends HTMLElement { #typeMap = {}; - #restoreType = (value, type) => { - switch (type) { - case "string": - return value; - case "number": - case "boolean": - return JSON.parse(value); - default: - return value; - } - }; + #restoreType = (value, type) => { + switch (type) { + case "string": + return value; + case "number": + case "boolean": + return JSON.parse(value); + default: + return value; + } + }; #handler(setter, typeMap) { const getKebab = (str) => { @@ -135,7 +133,6 @@ export class WebComponent extends HTMLElement { ); }; - return { set(obj, prop, value) { const oldValue = obj[prop]; @@ -151,7 +148,7 @@ export class WebComponent extends HTMLElement { } return true; - } + }, }; }