8000 fix(runtime-core): fix child node unloading in `v-for` · vuejs/core@80a2c6b · GitHub
[go: up one dir, main page]

Skip to content

Commit 80a2c6b

Browse files
fix(runtime-core): fix child node unloading in v-for
1 parent b775b71 commit 80a2c6b

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

packages/runtime-core/src/renderer.ts

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ import {
3535
NOOP,
3636
invokeArrayFns,
3737
isArray,
38-
getGlobalThis
38+
getGlobalThis,
39+
isString
3940
} from '@vue/shared'
4041
import {
4142
queueJob,
@@ -2117,19 +2118,31 @@ function baseCreateRenderer(
21172118
doRemove
21182119
)
21192120
} else if (
2120-
dynamicChildren &&
2121+
(dynamicChildren || children) &&
21212122
// #1153: fast path should not be taken for non-stable (v-for) fragments
21222123
(type !== Fragment ||
21232124
(patchFlag > 0 && patchFlag & PatchFlags.STABLE_FRAGMENT))
21242125
) {
2125-
// fast path for block nodes: only need to unmount dynamic children.
2126-
unmountChildren(
2127-
dynamicChildren,
2128-
parentComponent,
2129-
parentSuspense,
2130-
false,
2131-
true
2132-
)
2126+
if (dynamicChildren) {
2127+
// fast path for block nodes: only need to unmount dynamic children.
2128+
unmountChildren(
2129+
dynamicChildren,
2130+
parentComponent,
2131+
parentSuspense,
2132+
false,
2133+
true
2134+
)
2135+
}
2136+
2137+
if (children) {
2138+
// #9239
2139+
for (let i = 0; i < (children as VNode[]).length; i++) {
2140+
const child = (children as VNode[])[i]
2141+
if (child != null && !isString(child)) {
2142+
unmount(child, parentComponent, parentSuspense)
2143+
}
2144+
}
2145+
}
21332146
} else if (
21342147
(type === Fragment &&
21352148
patchFlag &

0 commit comments

Comments
 (0)
0