MCPcopy
hub / github.com/vuejs/core / remove

Function remove

packages/runtime-core/src/components/Teleport.ts:315–366  ·  view source on GitHub ↗
(
    vnode: VNode,
    parentComponent: ComponentInternalInstance | null,
    parentSuspense: SuspenseBoundary | null,
    { um: unmount, o: { remove: hostRemove } }: RendererInternals,
    doRemove: boolean,
  )

Source from the content-addressed store, hash-verified

313 },
314
315 remove(
316 vnode: VNode,
317 parentComponent: ComponentInternalInstance | null,
318 parentSuspense: SuspenseBoundary | null,
319 { um: unmount, o: { remove: hostRemove } }: RendererInternals,
320 doRemove: boolean,
321 ): void {
322 const {
323 shapeFlag,
324 children,
325 anchor,
326 targetStart,
327 targetAnchor,
328 target,
329 props,
330 } = vnode
331 const disabled = isTeleportDisabled(props)
332 const shouldRemove = doRemove || !disabled
333 // A deferred teleport inside a pending suspense may be unmounted before its
334 // content is ever mounted. Clear the queued mount effect; the children
335 // loop below is skipped because nothing has been mounted yet.
336 const pendingMount = pendingMounts.get(vnode)
337 if (pendingMount) {
338 pendingMount.flags! |= SchedulerJobFlags.DISPOSED
339 pendingMounts.delete(vnode)
340 }
341
342 if (target) {
343 hostRemove(targetStart!)
344 hostRemove(targetAnchor!)
345 }
346
347 // an unmounted teleport should always unmount its children whether it's disabled or not
348 doRemove && hostRemove(anchor!)
349 // #14876 don't unmount children if nothing was mounted
350 if (
351 !pendingMount &&
352 (disabled || target) &&
353 shapeFlag & ShapeFlags.ARRAY_CHILDREN
354 ) {
355 for (let i = 0; i < (children as VNode[]).length; i++) {
356 const child = (children as VNode[])[i]
357 unmount(
358 child,
359 parentComponent,
360 parentSuspense,
361 shouldRemove,
362 !!child.dynamicChildren,
363 )
364 }
365 }
366 },
367
368 move: moveTeleport as typeof moveTeleport,
369 hydrate: hydrateTeleport as typeof hydrateTeleport,

Callers 2

leaveFunction · 0.70
registerDepFunction · 0.70

Calls 3

isTeleportDisabledFunction · 0.85
unmountFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected