Skip to content

fix(runtime): patch innerHTML and innerText setters on scoped components - #6997

Merged
johnjenkins merged 1 commit into
mainfrom
fix/scoped-innerhtml-6972
Nov 11, 2026
Merged

johnjenkins merged 1 commit into
mainfrom
fix/scoped-innerhtml-6972

Conversation

@johnjenkins

@johnjenkins johnjenkins commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

What is the current behavior?

With experimentalSlotFixes, setting innerHTML or innerText on a scoped component that has a slot replaces every host child. That includes the content reference node (s-cr) and, once the component has rendered, its own rendered nodes. On the next render the new content can't be relocated into the slot, so it gets hidden and the component renders empty.

GitHub Issue Number: #6972

What is the new behavior?

Closes #6972

The innerHTML and innerText setters are patched alongside textContent. They now remove only the slotted light-DOM content, including light-DOM nodes that haven't been relocated yet, and insert the new content into the default slot:

  • innerHTML content goes through the patched insertAdjacentHTML.
  • innerText content is appended as a text node.

The getters are unchanged. The slotted-node removal used by the textContent setter is moved into a shared helper.

In keeping with light-dom content fixes - this is just for interop with frameworks (Vue's v-html, Svelte's {@html} and React's dangerouslySetInnerHTML) - not
an exhaustive list of all browser accessors / methods - this get accessors here have been left untouched.

Documentation

N/A

Does this introduce a breaking change?

  • Yes
  • No

Testing

New wdio test inner-content-patch:

  • innerHTML set before the first render renders in the default slot;
  • innerHTML set after the first render replaces only the slotted content, and the component's own template survives a re-render;
  • innerText is inserted as text, not markup.

@johnjenkins
johnjenkins requested a review from a team as a code owner November 11, 2026 11:27
@johnjenkins
johnjenkins merged commit a0f15ef into main Nov 11, 2026
31 checks passed
ShaneK pushed a commit to masimplo/ionic-framework that referenced this pull request Nov 12, 2026
Issue number: resolves ionic-team#31433

---------

## What is the current behavior?
Ionic uses `@stencil/core` 4.45.2. On scoped components, setting
`innerHTML` or `innerText` removes a marker node Stencil uses to track
slotted content, so the content is hidden on the next render.

## What is the new behavior?
- Updates `@stencil/core` to 4.45.3, which patches the `innerHTML` and
`innerText` setters on scoped components (stenciljs/core#6997).

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

## Other information
Regression tests for `ion-label` are added in
ionic-team#31739, which is
stacked on this PR.

Co-authored-by: Brandy Smith <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: setting innerHTML on a scoped component hides the new content

1 participant