Skip to content

Commit e62fe70

Browse files
committed
fix(Menubar): Move shadow root setup to connectedCallback
The custom element spec forbids inspecting children or attaching a shadow root in the constructor, which prevents the element from being cloned. Moving the template lookup and shadow root attachment to connectedCallback aligns Menubar with the other custom elements on this branch.
1 parent 97465c6 commit e62fe70

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

app/views/alchemy/_menubar.html.erb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,10 @@
114114

115115
<script type="module" data-turbo-eval="false">
116116
class Menubar extends HTMLElement {
117-
constructor() {
118-
super()
117+
connectedCallback() {
119118
const template = this.querySelector("template")
120119
const attachedShadowRoot = this.attachShadow({ mode: "open" })
121120
attachedShadowRoot.appendChild(template.content.cloneNode(true))
122-
}
123-
124-
connectedCallback() {
125121
const width = this.bar.offsetWidth
126122
this.bar.style = `--panel-width: ${width}px; --left-offset: calc(var(--icon-size) + 32px);`
127123
this.bar.addEventListener("touchstart", this, { passive: false })

0 commit comments

Comments
 (0)