Skip to content

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
alicewriteswrongs committed May 28, 2024
1 parent 302f66f commit 65b5fb8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/runtime/vdom/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function toVNode(node: Node): d.VNode {
for (let i = 0, l = childNodes.length; i < l; i++) {
childVnode = toVNode(childNodes[i]);
if (childVnode) {
(vnode.$children$ ||= []).push(childVnode);
(vnode.$children$ = vnode.$children$ || []).push(childVnode);
}
}
return vnode;
Expand Down
11 changes: 6 additions & 5 deletions src/runtime/vdom/vdom-render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -653,17 +653,18 @@ export const patch = (oldVNode: d.VNode, newVNode: d.VNode, isInitialRender = fa
const text = newVNode.$text$;
let defaultHolder: Comment;

if (BUILD.shadowDom && isInitialRender && oldVNode.$elm$.nodeType === NODE_TYPE.DocumentFragment) {
// TODO perhaps we should try to only do this when DSD has been used?
// although there may not be any harm in just doing it all the time.
//
// we need to create fake 'oldChildren' for any nodes that might be present
if (!BUILD.hydrateServerSide && BUILD.shadowDom && isInitialRender && oldVNode.$elm$.nodeType === NODE_TYPE.DocumentFragment) {
// We need to create fake 'oldChildren' for any nodes that might be present
// in the shadow root because of DSD. We want to do this when:
//
// 1. this is the first render
// 2. the `$elm$` for the current old vdom node is a document fragment,
// meaning the content node for a shadow root that was created by the
// browser based on a `<template>` tag in the HTML
//
// This will allow the component rendering lifecycle to boot up with vdom
// nodes for the DOM nodes already present in the shadow root, allowing the
// vdom to re-use these nodes (if they are suitable, of course).
for (const child of oldVNode.$elm$.children) {
// TODO be more fine-grained about this
// 1. can I tell whether the style tag was added client-side or not?
Expand Down

0 comments on commit 65b5fb8

Please sign in to comment.