-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
Fix: nested child elements can not be updated correctly, fix #5618 #5627
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: nested child elements can not be updated correctly, fix #5618 #5627
Conversation
28bc9a0 to
a95f3d0
Compare
|
Well, it's an interesting thing to name the title |
c262d62 to
9353514
Compare
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.
_renndered is set when process.env.NODE_ENV !== 'production'.
and not only slot, hand-written render functions could have this problem too.
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.
I did not find any problems in the render function
html:
<div id="app"></div>javascript:
var vm = new Vue({
el: '#app',
data: {
count: 1
},
render: function (h) {
var list = []
for (var i = 0; i < this.count; i++) {
list.push(h('span', [this.count]))
}
return h('div', [
list,
h('input', {attrs: {
value: 'a',
type: 'text'
}})
])
}
})You can input something in the input box,
then modify the value of count in the console
and input`s value did not changed
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.
Can you give me a example about hand-written render functions? 🌹
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.
@gebilaoxiong , demo, hack... maybe we should ignore it 😂
and _rendered is not set in production, see this line
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.
💋 Thanks , I'll take a look at this question
f5d07e6 to
094edcd
Compare
|
Now when using |
|
@gebilaoxiong , but all array in hand-written render function will not get a key, I don't know whether it is a good solution. |
|
I think this happens only when there are nested arrays in children just like: children: [
[vnode, vnode...]
]In the but so we just skip to set the key |
|
@pengchongfu wait, I have a better way to solve this problem! |
094edcd to
05da6e4
Compare
|
I marked the Only avoid |
t be rendered correctly, when render function and slot` to generated nested children, fix #5618
t be rendered correctly, when render function and slot` to generated nested children, fix #5618render function and slot created nested children can`t be rendered correctly, fix #5618
|
Well, it looks like I'm the last one waiting for today In addition to deleting the code, do we have other ways to solve this problem? 😄 |
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.
Instead of adding a property to every vnode, we can simply mark the ret array here with something like:
if (isDef(ret)) {
(ret: any)._isVList = true // work around flow
}Then check children._isVList in normalizeArrayChildren.
05da6e4 to
7ff077a
Compare
render function and slot created nested children can`t be rendered correctly, fix #5618|
Fix bug is really a very interesting thing Maybe my level is not enough, need to chew and get the truth |
|
I pushed a commit to ensure [[[v-for list], ..., [[v-for list]]] |
|
understand, thank you very much |
#5618
What kind of change does this PR introduce? (check at least one)
Does this PR introduce a breaking change? (check one)
If yes, please describe the impact and migration path for existing applications:
The PR fulfills these requirements:
devbranch for v2.x (or to a previous version branch), not themasterbranchfix #xxx[,#xxx], where "xxx" is the issue number)If adding a new feature, the PR's description includes:
Other information: