From 6b63b9f8c68212e4dbc460c27a2ef34ad410c484 Mon Sep 17 00:00:00 2001 From: Evan Chen Date: Mon, 18 Jul 2022 11:10:42 +0800 Subject: [PATCH] update --- index.html | 4 ++-- index.js | 19 ++++++++++--------- package.json | 4 ++-- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/index.html b/index.html index 31e1985..9ae3c79 100644 --- a/index.html +++ b/index.html @@ -9,11 +9,11 @@ content="Web site created using create-react-app" /> React App - + - + diff --git a/index.js b/index.js index ed25bd6..3c13232 100644 --- a/index.js +++ b/index.js @@ -26,12 +26,8 @@ WcTestApp.defaultProps = { class WcTest extends HTMLElement { root; - // declare attributes we want to keep track of - static get observedAttributes() { - return ['name', 'onclick']; - } - - connectedCallback() { + constructor(){ + super() let mountPoint = this; // ShadowRoot (global styles will not apply, but safer with a complete isolation layer) @@ -41,14 +37,19 @@ class WcTest extends HTMLElement { this.render() } - render(){ + // declare attributes we want to keep track of + static get observedAttributes() { + return ['name', 'onclick']; + } + + // connectedCallback() { + // } + render(){ const name = this.hasAttribute('name') ? this.getAttribute('name') : undefined; - console.log(this.root) - this.root.render(); } diff --git a/package.json b/package.json index c714372..efd934c 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,8 @@ "react-dom": "^18.2.0" }, "scripts": { - "start": "yarn parcel index.js index.css", - "build": "yarn parcel build index.js index.css" + "start": "yarn parcel index.html", + "build": "(rm -rf dist||true) && yarn parcel build index.html" }, "browserslist": { "production": [