Subscribe on changes!

render function, template and v-for Inconsistent performance

avatar
Sep 5th 2020

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

avatar
Sep 5th 2020

These three forms are consistent

Please be more precise, what do you exactly expect to be the same?

avatar
Sep 5th 2020

These three forms are consistent

Please be more precise, what do you exactly expect to be the same?

Slots length is not same.

avatar
Sep 5th 2020
avatar
Sep 10th 2020

in v3, v-for is compiled as a single fragment node. You will need to check the fragment's children for the list items.

avatar
Sep 13th 2020

@yyx990803 Why? Why I get this single fragment node when I getting slots? but in HTML I see only elements without the node

avatar
Mar 2nd 2021

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