Skip to content

Commit

Permalink
refactor(compiler-sfc): replace filter method with for loop (#4905)
Browse files Browse the repository at this point in the history
  • Loading branch information
btea committed Nov 15, 2021
1 parent 9c42a1e commit fd7c340
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/compiler-sfc/src/parse.ts
Expand Up @@ -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
}

0 comments on commit fd7c340

Please sign in to comment.