]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
refactor(runtime-core): simplify deep watch traverse (#2212)
authorPick <picknight@foxmail.com>
Tue, 13 Oct 2020 20:06:36 +0000 (04:06 +0800)
committerGitHub <noreply@github.com>
Tue, 13 Oct 2020 20:06:36 +0000 (16:06 -0400)
packages/runtime-core/src/apiWatch.ts

index 30a76b0f1a79bebb3e4d1e37e89aee001378c567..62592d3938cf93c9fa3c0e813d17f99b67e7e62d 100644 (file)
@@ -333,13 +333,8 @@ function traverse(value: unknown, seen: Set<unknown> = new Set()) {
     for (let i = 0; i < value.length; i++) {
       traverse(value[i], seen)
     }
-  } else if (isMap(value)) {
-    value.forEach((_, key) => {
-      // to register mutation dep for existing keys
-      traverse(value.get(key), seen)
-    })
-  } else if (isSet(value)) {
-    value.forEach(v => {
+  } else if (isSet(value) || isMap(value)) {
+    value.forEach((v: any) => {
       traverse(v, seen)
     })
   } else {