fix(wasm): declare private shadow field
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Virgil 2026-04-04 01:08:19 +00:00
parent f3c2bb1ca7
commit bfacf35c81
2 changed files with 2 additions and 0 deletions

View file

@ -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}}));}" +

View file

@ -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`)