Closed ZhenyaUsenko closed 2 weeks ago
That's Fragment's start and end anchor. Can using document.querySelector("#app > div").children
solve your problem?
I don't necessarily have a problem with that, thought those were not intentional
Can the anchors be omitted for single element fragments? It seems they are pretty common (e.g. v-for
+ v-if
)
Can the anchors be omitted for single element fragments? It seems they are pretty common (e.g. v-for + v-if)
No, this is intentionally designed to be this way.
Vue version
3.5.12
Link to minimal reproduction
https://play.vuejs.org/#eNp9kc1OwzAQhF/F8qWXklIKlyogAeoBDoCAoyUUJZvg4tiWf0KkKu/O2mkaolb1aT3feD1r7+i91knjga5p6qDWInNwxyQhacGbWGA5ANJclMrczjjhkiwvZ3s+dfASDSPad8rGlS7G1kgXk2uPhME9kXFrc8O1Ixac1xH3ApZ0Tp3NlSx5lWytkjjaLnRiNFe15gLMq3ZcScvomkQSWCaE+n2OmjMe5oOef0P+c0Lf2jZojL4ZsGAaYPTAXGYqcD3efLxAi/UB1qrwAt1n4DtYJXzI2NsevCww9j9fTPtUa2Ucl9Wn3bQOpB2GCkGDs4t+RvF/H8+MPsZdJdfxHJMdvuJXAyb0xAdcJTfJ8op2f18fsvM=
Steps to reproduce
Use
document.querySelector("#app > div").childNodes
in consoleWhat is expected?
NodeList
length should be 10What is actually happening?
NodeList
length is 32System Info
Any additional comments?
Vue creates redundant empty text nodes around
template
(fragment)compilerOptions.whitespace
does NOT helptemplate
does NOT helptemplate
tags and usingv-for
on the div element DOES fix the issue