|
|
@@ -21,6 +21,7 @@ import { warn } from '@vue/runtime-dom'
|
|
|
import { currentInstance, isVaporComponent } from './component'
|
|
|
import type { DynamicSlot } from './componentSlots'
|
|
|
import { renderEffect } from './renderEffect'
|
|
|
+import { VaporVForFlags } from '../../shared/src/vaporFlags'
|
|
|
|
|
|
class ForBlock extends VaporFragment {
|
|
|
scope: EffectScope | undefined
|
|
|
@@ -64,13 +65,7 @@ export const createFor = (
|
|
|
index: ShallowRef<number | undefined>,
|
|
|
) => Block,
|
|
|
getKey?: (item: any, key: any, index?: number) => any,
|
|
|
- /**
|
|
|
- * Whether this v-for is used directly on a component. If true, we can avoid
|
|
|
- * creating an extra fragment / scope for each block
|
|
|
- */
|
|
|
- isComponent = false,
|
|
|
- once?: boolean,
|
|
|
- canUseFastRemove?: boolean,
|
|
|
+ flags = 0,
|
|
|
// hydrationNode?: Node,
|
|
|
): VaporFragment => {
|
|
|
let isMounted = false
|
|
|
@@ -80,6 +75,8 @@ export const createFor = (
|
|
|
const parentAnchor = __DEV__ ? createComment('for') : createTextNode()
|
|
|
const frag = new VaporFragment(oldBlocks)
|
|
|
const instance = currentInstance!
|
|
|
+ const canUseFastRemove = flags & VaporVForFlags.FAST_REMOVE
|
|
|
+ const isComponent = flags & VaporVForFlags.IS_COMPONENT
|
|
|
|
|
|
if (__DEV__ && !instance) {
|
|
|
warn('createFor() can only be used inside setup()')
|
|
|
@@ -354,7 +351,11 @@ export const createFor = (
|
|
|
doRemove && removeBlock(nodes, parent!)
|
|
|
}
|
|
|
|
|
|
- once ? renderList() : renderEffect(renderList)
|
|
|
+ if (flags & VaporVForFlags.ONCE) {
|
|
|
+ renderList()
|
|
|
+ } else {
|
|
|
+ renderEffect(renderList)
|
|
|
+ }
|
|
|
return frag
|
|
|
}
|
|
|
|