This commit is contained in:
metacryst
2023-06-21 14:02:31 -05:00
commit c511fda61a
3 changed files with 52 additions and 0 deletions

11
dom.js Normal file
View File

@@ -0,0 +1,11 @@
export function addStyle(cssString) {
let stylesheet = new CSSStyleSheet();
stylesheet.replaceSync(cssString)
document.adoptedStyleSheets = [...document.adoptedStyleSheets, stylesheet];
}
export function create(elementString) {
let parser = new DOMParser();
let doc = parser.parseFromString(elementString, 'text/html');
return doc.body.firstChild;
}

11
index.html Normal file
View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Index</title>
</head>
<body>
<script type="module" src="index.js"></script>
</body>
</html>

30
index.js Normal file
View File

@@ -0,0 +1,30 @@
import * as dom from './dom.js';
window.dom = {};
Object.entries(dom).forEach(([name, exported]) => window.dom[name] = exported);
class Index extends HTMLElement {
css = /*css*/ `
`
html = /*html*/ `
`
constructor() {
super();
dom.addStyle(this.css);
this.innerHTML = this.html;
}
connectedCallback() {
}
}
customElements.define('index-el', Index);
export default Index;