Skip to content

Commit

Permalink
feat: handle light dom components
Browse files Browse the repository at this point in the history
  • Loading branch information
jodarove committed Sep 27, 2021
1 parent 93862f0 commit 636ed99
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 7 additions & 1 deletion packages/@lwc/engine-core/src/framework/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,13 @@ const CustomElementHook: Hooks<VCustomElement> = {
}
runConnectedCallback(vm);
}
hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vm);

if (!(vm && vm.renderMode === RenderMode.Light)) {
// VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
// Note: for Light DOM, this is handled while hydrating the VM
hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vm);
}

if (vm) {
hydrateVM(vm);
}
Expand Down
4 changes: 3 additions & 1 deletion packages/@lwc/engine-core/src/framework/vm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,9 @@ function hydrate(vm: VM) {
const children = renderComponent(vm);
vm.children = children;

hydrateChildrenHook(vm.elm.shadowRoot.childNodes, children, vm);
const vmChildren =
vm.renderMode === RenderMode.Light ? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
hydrateChildrenHook(vmChildren, children, vm);

runRenderedCallback(vm);
}
Expand Down

0 comments on commit 636ed99

Please sign in to comment.