Skip to content

Commit 222ced2

Browse files
committed
perf(vapor): optimize v-if in once mode
1 parent 5d1c6ca commit 222ced2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type BlockFn, DynamicFragment } from './block'
1+
import { type Block, type BlockFn, DynamicFragment } from './block'
22
import { renderEffect } from './renderEffect'
33

44
export function createIf(
@@ -7,12 +7,12 @@ export function createIf(
77
b2?: BlockFn,
88
once?: boolean,
99
// hydrationNode?: Node,
10-
): DynamicFragment {
11-
const frag = __DEV__ ? new DynamicFragment('if') : new DynamicFragment()
10+
): Block {
1211
if (once) {
13-
frag.update(condition() ? b1 : b2)
12+
return condition() ? b1() : b2 ? b2() : []
1413
} else {
14+
const frag = __DEV__ ? new DynamicFragment('if') : new DynamicFragment()
1515
renderEffect(() => frag.update(condition() ? b1 : b2))
16+
return frag
1617
}
17-
return frag
1818
}

0 commit comments

Comments
 (0)