-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #20 #33
base: develop
Are you sure you want to change the base?
Fix #20 #33
Conversation
Not too sure why this works, or rather, why it doesn’t work without this rather strange approach. Unless I’m mistaken, the correct return value when `nodes.length < 2 && !nodes[0].text` is true should be `nodes[0]` rather than just `nodes` (as `nodes` is an array, not a VNode). However, returning just `nodes[0]` does not fix the bug where the portal contents don’t render as described in LinusBorg#20. Calling `createElement` on its constituent parts works, despite the output of the function and the initial `nodes[0]` VNode appearing identical upon inspection.
@@ -14,7 +14,7 @@ export default Vue.extend({ | |||
const nodes = this.updatedNodes && this.updatedNodes() | |||
if (!nodes) return h() | |||
return nodes.length < 2 && !nodes[0].text | |||
? nodes | |||
? h(nodes[0].tag, nodes[0].data, nodes[0].children) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! So as I just explained in #20, I can't reproduce this locally, which might be due to the version of Vue I'm using vs. people reporting this issue.
Nonetheless, it would be more correct to simply return the single node like this:
? h(nodes[0].tag, nodes[0].data, nodes[0].children) | |
? node[0] |
Can you verify wether this works for you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello! Thank you for getting back to me.
In the latest version of Vue, this issue appears to no longer be occurring. Unfortunately, even though I went back to the version that was current at the time I opened the PR (2.6.9), and then to 2.6.8, I can't replicate it there anymore either.
I do remember that just returning the single node (as per your suggested change) didn't work, because it was the first thing I tried and I couldn't understand why (or why wrapping its data in a call to h()
did work).
I'm sorry I can't be more help!
Not too sure why this works, or rather, why it doesn’t work without this rather strange approach.
Unless I’m mistaken, the correct return value when
nodes.length < 2 && !nodes[0].text
is true should benodes[0]
rather than justnodes
(asnodes
is an array, not a VNode).However, returning just
nodes[0]
does not fix the bug where the portal contents don’t render as described in #20. CallingcreateElement
on its constituent parts is working, but as far as I can tell, the output of the function and the initialnodes[0]
VNode are identical. Does a VNode have some sort of affinity to its parent component maybe?