Skip to content

Commit

Permalink
fix(runtime-core): Revert to using InternalObjectKey for normalized s…
Browse files Browse the repository at this point in the history
…lots to prevent reassigning _ctx
  • Loading branch information
Vadim Kruglov committed Apr 16, 2024
1 parent b4b856b commit a646a83
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/runtime-core/src/componentSlots.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { type ComponentInternalInstance, currentInstance } from './component'
import {
InternalObjectKey,
type VNode,
type VNodeChild,
type VNodeNormalizedChildren,
Expand Down Expand Up @@ -187,6 +188,8 @@ export const initSlots = (
normalizeVNodeSlots(instance, children)
}
}

def(instance.slots, InternalObjectKey, 1)
}

export const updateSlots = (
Expand Down
4 changes: 3 additions & 1 deletion packages/runtime-core/src/vnode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,8 @@ const createVNodeWithArgsTransform = (
)
}

export const InternalObjectKey = `__vInternal`

const normalizeKey = ({ key }: VNodeProps): VNode['key'] =>
key != null ? key : null

Expand Down Expand Up @@ -791,7 +793,7 @@ export function normalizeChildren(vnode: VNode, children: unknown) {
} else {
type = ShapeFlags.SLOTS_CHILDREN
const slotFlag = (children as RawSlots)._
if (!slotFlag) {
if (!slotFlag && !(InternalObjectKey in children!)) {
// if slots are not normalized, attach context instance
// (compiled / normalized slots already have context)
;(children as RawSlots)._ctx = currentRenderingInstance
Expand Down

0 comments on commit a646a83

Please sign in to comment.