#5393·lit

Overriding ElementInternals values has no effect with Lit SSR

Author: vollowxCreated Oct 1, 2026Updated Oct 1, 2026

Which package(s) are affected?

SSR (@lit-labs/ssr)

Description

When a component has ARIA properties set in its ElementInternals, like role and ariaDisabled, and another component that use it overrides one of those, like below:

typescript
class AElement extends LitElement {
    constructor() {
        super();
        this.internals_ = this.attachInternals();
        this.internals_.role = "menu";
    }
}

class BElement extends LitElement {
    render() {
        return html`
            <a-element role="listbox"></a-element>
        `;
    }
}
xml
<b-element></b-element>

and then SSR:

<b-element ...>
    <template ...>
        <a-element role="listbox" hydrate-internals-role="menu" ...>...</a-element>
    </template>
</b-element>

it is all good until lit-hydrate-support.js starts working - it unconditionally removes both role and hydrate-internals-role, and eventually leaving the role of a-element "menu" instead of "listbox".

Reproduction

  1. https://tideover.cc/seele/docs/m3/playground/
  2. Right click and inspect any select, i.e. Button->Variant, then choose the nearest <md-outlined-select> in dev tools
  3. Open #shadow-root, choose the nearest <md-menu> inside <md-popup>

Notice that it has no [role=listbox], while that is coded here

Workaround

Replace this code block with

typescript
for (const attrName of this.getAttributeNames()) {
  if (attrName.startsWith(HYDRATE_INTERNALS_ATTR_PREFIX)) {
    const ariaAttr = attrName.slice(HYDRATE_INTERNALS_ATTR_PREFIX.length);
    const recordedValue = this.getAttribute(attrName);
    const liveValue = this.getAttribute(ariaAttr);
    if (liveValue === recordedValue) {
      this.removeAttribute(ariaAttr);
    }
    this.removeAttribute(attrName);
  }
}

Is this a regression?

No or unsure. This never worked, or I haven't tried before.

Affected versions

Any

Browser/OS/Node environment

Browser: Helium 0.18.1.1 (Chromium 154.0.8037.57) OS: Windows 11 Build 26340.9502