From eb7b786bdd2020ca54ee427fcaf327f8b27bb8cf Mon Sep 17 00:00:00 2001 From: Matthew Huntington Date: Sat, 8 Feb 2025 10:01:10 -0500 Subject: [PATCH] basic component --- component.js | 17 +++++++++++++++++ index.html | 11 +++++++++++ 2 files changed, 28 insertions(+) create mode 100644 component.js create mode 100644 index.html diff --git a/component.js b/component.js new file mode 100644 index 0000000..f65d5a2 --- /dev/null +++ b/component.js @@ -0,0 +1,17 @@ +class MyComponent extends HTMLElement { + constructor() { + super(); + + const shadow = this.attachShadow({ mode: 'closed' }); + + const root = document.createElement('section'); + root.innerHTML = ` +

Hello from MyComponent!

+ `; + + shadow.appendChild(root) + } +} + +customElements.define('my-component', MyComponent); + diff --git a/index.html b/index.html new file mode 100644 index 0000000..c32ad17 --- /dev/null +++ b/index.html @@ -0,0 +1,11 @@ + + + + + + + + + + +