wc-compiler
Advanced tools
Comparing version 0.3.0 to 0.3.1
{ | ||
"name": "wc-compiler", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Experimental native Web Components compiler.", | ||
@@ -5,0 +5,0 @@ "main": "src/wcc.js", |
@@ -6,2 +6,3 @@ // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget | ||
// EventTarget <- Node | ||
// TODO should be an interface? | ||
class Node extends EventTarget { | ||
@@ -19,3 +20,3 @@ constructor() { | ||
appendChild(node) { | ||
this.innerHTML = this.innerHTML ? this.innerHTML += node.textContent : node.textContent; | ||
this.innerHTML = this.innerHTML ? this.innerHTML += node.innerHTML : node.innerHTML; | ||
} | ||
@@ -68,10 +69,5 @@ } | ||
// https://github.com/mfreed7/declarative-shadow-dom/blob/master/README.md#serialization | ||
// eslint-disable-next-line | ||
getInnerHTML(options = {}) { | ||
return options.includeShadowRoots | ||
? ` | ||
<template shadowroot="${this.shadowRoot.mode}"> | ||
${this.shadowRoot.innerHTML} | ||
</template> | ||
` | ||
: this.shadowRoot.innerHTML; | ||
return this.shadowRoot.innerHTML; | ||
} | ||
@@ -107,8 +103,17 @@ } | ||
this.content = new DocumentFragment(this.innerHTML); | ||
this.content = new DocumentFragment(); | ||
} | ||
// TODO open vs closed shadow root | ||
set innerHTML(html) { | ||
this.content.textContent = html; | ||
this.content.innerHTML = ` | ||
<template shadowroot="open"> | ||
${html} | ||
</template> | ||
`; | ||
} | ||
get innerHTML() { | ||
return this.content && this.content.innerHTML ? this.content.innerHTML : undefined; | ||
} | ||
} | ||
@@ -115,0 +120,0 @@ |
12754
256