Textarea content still maintain when I leave the router and go to new router
Version
3.2.27
Reproduction link
Steps to reproduce
- click Index link
- click Editor link
- click back button
- click new Editor link
What is expected?
When I click the editor link, it show "hello world" in textarea, click back button and click newEditor should show nothing in textarea.
What is actually happening?
When I click the editor link, it show "hello world" in textarea, click back button and click newEditor is still show "hello world"
- I found it work when I use development version.
- In production version, I still found two ways can work. add ref or put the div with id "editor" in root div in components. It seems not destroy the div, even if I make quillEditor is null.
I think this has nothing to do with vue.
// if new content is not empty it works fine.
this.content = Number(this.create) ? "<p>Hello World!</p>" : "new val";
I think this has nothing to do with vue.
// if new content is not empty it works fine. this.content = Number(this.create) ? "<p>Hello World!</p>" : "new val";
But in vue2 it works good. https://codepen.io/cyanxxx/pen/LYzarZP
I think this has nothing to do with vue.
// if new content is not empty it works fine. this.content = Number(this.create) ? "<p>Hello World!</p>" : "new val";
But in vue2, same code can work well. https://codepen.io/cyanxxx/pen/LYzarZP
Your reproduction is not minimal, please read and follow https://new-issue.vuejs.org/?repo=vuejs/vue-next#why-repro when reporting a bug. Most bugs should be reproducible with the SFC Playground. Try reproducing without quill or router.
Your reproduction is not minimal, please read and follow https://new-issue.vuejs.org/?repo=vuejs/vue-next#why-repro when reporting a bug. Most bugs should be reproducible with the SFC Playground. Try reproducing without quill or router.
Finally, I find the problem. Because the hoisted vnode. The '#editor' will be consider as static element. First time will be created and the second time beacuse the vnode was created before, the vnode.el already been set. So it just clone the el element. And because the branch condition, development will not cloneNode so the development environment work. And production not work. https://github.com/vuejs/core/blob/4e7b36f5c3ee72cb9554982dd174f1989d5488f6/packages/runtime-core/src/renderer.ts#L632