refactor(compiler-sfc): replace filter method with for loop (#4905)

This commit is contained in:
btea 2021-11-14 20:31:44 -06:00 committed by GitHub
parent 9c42a1e2a3
commit fd7c3407c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View 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
}