From 521da9591e7a7544c7f6d3c609430b097a7eb0e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=A8=E7=93=9C=E4=B8=B8?= Date: Sun, 20 Dec 2020 23:29:32 +0900 Subject: [PATCH] [fix] --- main.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/main.js b/main.js index a0f66c5..5023416 100644 --- a/main.js +++ b/main.js @@ -53,6 +53,15 @@ export class Component extends HTMLElement{ await this.dispatch('init'); if(this.afterFirstUpdate) this.afterFirstUpdate(); } + attr(key, default_value = undefined) { + return this.hasAttribute(key) ? this.getAttribute(key) : default_value; + } + prop(key, default_value = undefined) { + return this[key] ? this[key] : default_value; + } + init() { + return {}; + } updatecontext(state){ return {...state} }