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 ionic-team#5335
  • Loading branch information
yigityuce committed Feb 15, 2024
1 parent 8de2ab5 commit 1c917c3
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 @@ -204,10 +204,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 1c917c3

Please sign in to comment.