mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-01-06 12:17:13 +08:00
perf(flatten): use o(n) implementation
This commit is contained in:
parent
a435b7127d
commit
d89bd58a00
@ -1,10 +1,10 @@
|
||||
import { Fragment } from 'vue'
|
||||
|
||||
export function flatten (vNodes) {
|
||||
let result = []
|
||||
// o(n) flatten
|
||||
export function flatten (vNodes, result = []) {
|
||||
vNodes.forEach(vNode => {
|
||||
if (vNode.type === Fragment) {
|
||||
result = result.concat(flatten(vNode.children))
|
||||
flatten(vNode.children, result)
|
||||
} else {
|
||||
result.push(vNode)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user