From: btea <2356281422@qq.com> Date: Mon, 15 Nov 2021 02:31:44 +0000 (-0600) Subject: refactor(compiler-sfc): replace filter method with for loop (#4905) X-Git-Tag: v3.2.22~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fd7c3407c79e86bf98c8497fed2e0f68d26a733c;p=thirdparty%2Fvuejs%2Fcore.git refactor(compiler-sfc): replace filter method with for loop (#4905) --- diff --git a/packages/compiler-sfc/src/parse.ts b/packages/compiler-sfc/src/parse.ts index 5afdb47f6d..946435f6b9 100644 --- a/packages/compiler-sfc/src/parse.ts +++ b/packages/compiler-sfc/src/parse.ts @@ -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 }