File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
packages/runtime-vapor/src Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 1- import type { Block , BlockFn } from './block'
1+ import { type Block , type BlockFn , insert } from './block'
2+ import { advanceHydrationNode , isHydrating } from './dom/hydration'
23import { DynamicFragment } from './fragment'
4+ import {
5+ insertionAnchor ,
6+ insertionParent ,
7+ isLastInsertion ,
8+ resetInsertionState ,
9+ } from './insertionState'
310import { renderEffect } from './renderEffect'
411
512export function createKeyedFragment ( key : ( ) => any , render : BlockFn ) : Block {
13+ const _insertionParent = insertionParent
14+ const _insertionAnchor = insertionAnchor
15+ const _isLastInsertion = isLastInsertion
16+ if ( ! isHydrating ) resetInsertionState ( )
17+
618 const frag = __DEV__ ? new DynamicFragment ( 'keyed' ) : new DynamicFragment ( )
719 renderEffect ( ( ) => {
820 frag . update ( render , key ( ) )
921 } )
22+
23+ if ( ! isHydrating ) {
24+ if ( _insertionParent ) insert ( frag , _insertionParent , _insertionAnchor )
25+ } else {
26+ if ( _isLastInsertion ) {
27+ advanceHydrationNode ( _insertionParent ! )
28+ }
29+ }
1030 return frag
1131}
You can’t perform that action at this time.
0 commit comments