]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
refactor(compiler-sfc): replace filter method with for loop (#4905)
authorbtea <2356281422@qq.com>
Mon, 15 Nov 2021 02:31:44 +0000 (20:31 -0600)
committerGitHub <noreply@github.com>
Mon, 15 Nov 2021 02:31:44 +0000 (21:31 -0500)
packages/compiler-sfc/src/parse.ts

index 5afdb47f6d5cf36596ba6be02a79c6ba3410c73d..946435f6b9eafd5ba8add6cf0a21557827d7e0f0 100644 (file)
@@ -404,9 +404,11 @@ function hasSrc(node: ElementNode) {
  * once the empty text nodes (trimmed content) have been filtered out.
  */
 function isEmpty(node: ElementNode) {
-  return (
-    node.children.filter(
-      child => child.type !== NodeTypes.TEXT || child.content.trim() !== ''
-    ).length === 0
-  )
+  for (let i = 0; i < node.children.length; i++) {
+    const child = node.children[i]
+    if (child.type !== NodeTypes.TEXT || child.content.trim() !== '') {
+      return false
+    }
+  }
+  return true
 }