fix(wasm): declare private shadow field
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
f3c2bb1ca7
commit
bfacf35c81
2 changed files with 2 additions and 0 deletions
|
|
@ -60,6 +60,7 @@ func jsStringLiteral(s string) string {
|
|||
func customElementClassSource(tag, slot string) string {
|
||||
className := tagToClassName(tag)
|
||||
return "class " + className + " extends HTMLElement {" +
|
||||
"#shadow;" +
|
||||
"constructor(){super();this.#shadow=this.attachShadow({mode:\"closed\"});}" +
|
||||
"connectedCallback(){this.#shadow.textContent=\"\";const slot=this.getAttribute(\"data-slot\")||" + jsStringLiteral(slot) + ";" +
|
||||
"this.dispatchEvent(new CustomEvent(\"wc-ready\",{detail:{tag:" + jsStringLiteral(tag) + ",slot}}));}" +
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ func TestCustomElementClassSource(t *testing.T) {
|
|||
src := customElementClassSource(`nav-bar`, `H`)
|
||||
|
||||
assert.Contains(t, src, `class NavBar extends HTMLElement`)
|
||||
assert.Contains(t, src, `#shadow;`)
|
||||
assert.Contains(t, src, `mode:"closed"`)
|
||||
assert.Contains(t, src, `#shadow`)
|
||||
assert.Contains(t, src, `data-slot`)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue