render function, template and v-for Inconsistent performance
Version
3.0.0-rc.10
Reproduction link
https://codesandbox.io/s/holy-night-tcdjf?file=/src/App.vue
Steps to reproduce
When I render default slot with render function, template and v-for, I found that they were not the same. Please see the test example for specific performance.
What is expected?
These three forms are consistent
What is actually happening?
These three forms are not consistent
These three forms are consistent
Please be more precise, what do you exactly expect to be the same?
Slots length is not same.
In V2, children length is same
Link: https://codesandbox.io/s/serene-bouman-mwe4y?file=/src/App.vue
in v3, v-for
is compiled as a single fragment node. You will need to check the fragment's children for the list items.
@yyx990803 Why? Why I get this single fragment node when I getting slots? but in HTML I see only elements without the node
in v3,
v-for
is compiled as a single fragment node. You will need to check the fragment's children for the list items.
@yyx990803 But i need to traverse the slot array and check slot type. How should I know that slot is a v-for fragment node and traverse it's children
// 过滤注释节点
const isCommentNode = slot.type === h().type
...
// 展开v-for节点
// const isVForNode = slot.type === ?
// const isVForNode = slot.type === Array.isArray(slot.children)
...
// 判断直接子元素是否为Tab组件
const isTab = slot.type === Tab.type