From fb3c3055064384e36c749033f9d2afd73f7a5a4a Mon Sep 17 00:00:00 2001 From: xiaodemen Date: Mon, 19 Dec 2022 17:06:28 +0800 Subject: [PATCH] fix(patch): clone insert hooks to avoid being mutated during iteration --- src/core/vdom/patch.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/vdom/patch.ts b/src/core/vdom/patch.ts index d0594863e3b..173840787bc 100644 --- a/src/core/vdom/patch.ts +++ b/src/core/vdom/patch.ts @@ -878,8 +878,11 @@ export function createPatchFunction(backend) { const insert = ancestor.data.hook.insert if (insert.merged) { // start at index 1 to avoid re-invoking component mounted hook - for (let i = 1; i < insert.fns.length; i++) { - insert.fns[i]() + // clone insert hooks to avoid being mutated during iteration. + // e.g. for customed directives under transition group. + const cloned = insert.fns.slice(1) + for (let i = 0; i < cloned.length; i++) { + cloned[i]() } } } else {