v-html can not reselect content when content change!
See original GitHub issueVersion
2.5.2
Reproduction link
https://jsfiddle.net/weituotian/0rc7zq1b/5/
Steps to reproduce
- select
h11111111111111111
- click
rerender
button - then you can see the selected can not be reselected
What is expected?
I hope I can update incrementally so that my html content can be selected back to the previous selection.
What is actually happening?
If the html changes, then the window.getSelection().addRange
can not choose to go back to the previous content.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Can't select html text - Stack Overflow
The solution is to use margin-left not padding left. Share. Share a link to this answer.
Read more >Can't change HTML content successfully - JavaScript - SitePoint
The problem is that the the text within <em> tags changes after the script is executed but I don't know why the text...
Read more >The HTML Option element - MDN Web Docs - Mozilla
The content of this attribute represents the value to be submitted with the form, should this option be selected.
Read more >user-select - CSS-Tricks
The user-select property in CSS controls how the text in an element is allowed to be selected. For example, it can be used...
Read more >Changing fonts - Squarespace Help Center
Any site text currently using that font won't change, but if you switch to a different font, you can't switch back. Instead, we...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Calm down plz.
Of course you can, you just need to decide how to record previous selections yourself, even with
v-html
.Absolutely not. By using
v-html
like this you are explicitly re-rendering all existing content, that’s why the selections are discarded. If you are just appending content, just try to keep previous content as much as possible and the selection will be preserved.You can check on this: http://jsfiddle.net/eywraw8t/143042/
And btw, don’t take free help for granted.
@Justineo The example may be written in error, It should be so