Skip to content

Commit

Permalink
refactor: review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jodarove committed Feb 26, 2022
1 parent f611656 commit d6b522e
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/@lwc/engine-core/src/framework/rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ function mountSlot(vnode: VSlot, parent: ParentNode, anchor: Node | null, vm: VM
const { aChildren } = vnode;

// weather to render the slotted content or the default slot content.
const children: VNodes = aChildren ? aChildren.vnodes : vnode.children;
const children: VNodes = isUndefined(aChildren) ? vnode.children : aChildren.vnodes;

// default content is part of vm.
const slottedContentOwnerVM = aChildren ? aChildren.owner : vm;
const slottedContentOwnerVM = isUndefined(aChildren) ? vm : aChildren.owner;

if (vm.renderMode === RenderMode.Light) {
mountVNodes(children, parent, anchor, 0, children.length, slottedContentOwnerVM);
Expand Down Expand Up @@ -225,10 +225,12 @@ function patchSlot(n1: VSlot, n2: VSlot, vm: VM) {
const { aChildren: oldAllocatedChildren } = n1;
const { aChildren } = n2;

const children = aChildren ? aChildren.vnodes : n2.children;
const oldChildren = oldAllocatedChildren ? oldAllocatedChildren.vnodes : n1.children;
const children = isUndefined(aChildren) ? n2.children : aChildren.vnodes;
const oldChildren = isUndefined(oldAllocatedChildren)
? n1.children
: oldAllocatedChildren.vnodes;

const owner = aChildren ? aChildren.owner : vm;
const owner = isUndefined(aChildren) ? vm : aChildren.owner;

if (vm.renderMode === RenderMode.Light) {
// Note: In light dom, there will always be a marker at the beginning (and the end) of the slotted content
Expand Down Expand Up @@ -350,7 +352,7 @@ function unmount(vnode: VNode, parent: ParentNode, doRemove: boolean = false) {
switch (type) {
case VNodeType.Slot:
unmountVNodes(
vnode.aChildren ? vnode.aChildren.vnodes : vnode.children,
isUndefined(vnode.aChildren) ? vnode.children : vnode.aChildren.vnodes,
(elm as ParentNode) ?? parent,
doRemove
);
Expand Down

0 comments on commit d6b522e

Please sign in to comment.