nude-element
Advanced tools
Comparing version 0.0.9 to 0.0.10
{ | ||
"name": "nude-element", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"description": "Composable web component helpers", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -16,3 +16,7 @@ /** | ||
super(); | ||
this.constructor.init(); | ||
if (!this.constructor[classInitialized]) { | ||
this.constructor.init(); | ||
} | ||
this.constructor.hooks.run("start", this); | ||
@@ -35,2 +39,11 @@ | ||
if (this.constructor.globalStyleSheet) { | ||
let rootNode = this.getRootNode(); | ||
if (!rootNode.querySelector(`style[data-for="${this.constructor.tagName}"]`)) { | ||
let root = rootNode.nodeType === Node.DOCUMENT_NODE ? rootNode.head : rootNode; | ||
root.append(this.constructor.globalStyleSheet.cloneNode(true)); | ||
} | ||
} | ||
this.constructor.hooks.run("connected", this); | ||
@@ -46,3 +59,3 @@ } | ||
if (this[classInitialized]) { | ||
return; | ||
return false; | ||
} | ||
@@ -64,5 +77,11 @@ | ||
if (this.globalStyle) { | ||
this.globalStyleSheet = document.createElement("style"); | ||
this.globalStyleSheet.dataset.for = this.tagName; | ||
this.globalStyleSheet.textContent = `@import url("${this.globalStyle}")`; | ||
} | ||
this.hooks.run("setup", this); | ||
this[classInitialized] = true; | ||
return this[classInitialized] = true; | ||
} | ||
@@ -69,0 +88,0 @@ } |
@@ -39,3 +39,4 @@ import * as allTypes from "./types/index.js"; | ||
if (type) { | ||
let {is: Type, ...typeOptions} = resolve(type); | ||
type = resolve(type); | ||
let {is: Type, ...typeOptions} = type; | ||
let parse = types.get(Type)?.parse; | ||
@@ -42,0 +43,0 @@ |
68322
1662