Skip to content

Commit

Permalink
fix(runtime): apply textnodes to shadow DOM instead of light dom
Browse files Browse the repository at this point in the history
fixes ionic-team#4231

By default the `vdomRender` build flag is `false`. The Stencil parser detects any usage of a `h` function, this flag will be switched. In the component provided by author of the bug there hasn't been any vDOM to be parsed, therefor there was no usage of the function `h`.

Now, in `callRender` if we end up not having to render any vDOM we used to just attach the string (can also be a boolean or number) as text to the host element. This however doesn't work when a shadow DOM is registered for the component. In this case the text content is added to the light dom which is not being rendered.

To fix this we check if the component has a shadow DOM if attach the text node to that node.
  • Loading branch information
Hans Claasen authored and HansClaasen committed Oct 19, 2023
1 parent c9a3eac commit b9caf0c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/runtime/update-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,12 @@ const callRender = (hostRef: d.HostRef, instance: any, elm: HTMLElement, isIniti
renderVdom(hostRef, instance, isInitialLoad);
}
} else {
elm.textContent = instance;
const shadowRoot = elm.shadowRoot;
if (BUILD.shadowDom) {
shadowRoot.textContent = instance;
} else {
elm.textContent = instance;
}
}
}
} catch (e) {
Expand Down

0 comments on commit b9caf0c

Please sign in to comment.