Skip to content

Commit

Permalink
fix(renderer): fix conditional rendering issue
Browse files Browse the repository at this point in the history
fix conditional rendering issue by applying to find actual DOM element(s) when about the relocate element is slot ref

fixes one of the issues raised in #5335
  • Loading branch information
yigityuce authored and rwaskiewicz committed Mar 13, 2024
1 parent 41f877e commit eb6f447
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/runtime/vdom/vdom-render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,19 @@ const relocateToHostRoot = (parentElm: Element) => {
plt.$flags$ &= ~PLATFORM_FLAGS.isTmpDisconnected;
};

const putBackInOriginalLocation = (parentElm: Node, recursive: boolean) => {
const putBackInOriginalLocation = (parentElm: d.RenderNode, recursive: boolean) => {
plt.$flags$ |= PLATFORM_FLAGS.isTmpDisconnected;
const oldSlotChildNodes: ChildNode[] = Array.from(parentElm.childNodes);

if (parentElm['s-sr']) {
let node = parentElm;
while ((node = node.nextSibling as d.RenderNode)) {
if (node && node['s-sn'] === parentElm['s-sn'] && node['s-sh'] === hostTagName) {
oldSlotChildNodes.push(node);
}
}
}

const oldSlotChildNodes = parentElm.childNodes;
for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
const childNode = oldSlotChildNodes[i] as any;
if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
Expand Down

0 comments on commit eb6f447

Please sign in to comment.