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. * once the empty text nodes (trimmed content) have been filtered out.
*/ */
function isEmpty(node: ElementNode) { function isEmpty(node: ElementNode) {
return ( for (let i = 0; i < node.children.length; i++) {
node.children.filter( const child = node.children[i]
child => child.type !== NodeTypes.TEXT || child.content.trim() !== '' if (child.type !== NodeTypes.TEXT || child.content.trim() !== '') {
).length === 0 return false
) }
}
return true
} }