Set value property before selectionEnd and selectionStart #157
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changing the
value
property of atextarea
also implicitly changes (step 4) itsselectionEnd
andselectionStart
properties. Since virtual-dom isn't aware of this, the in-memory copy of the dom now differs from the real dom in these properties, leading to bugs.Adding the logic to handle this properly requires handling a lot of edge cases, so I couldn't find a nice way to implement it considering that these properties are uncommon and code size is important, hence this hotfix.
This hotfix always considers the
selectionStart
andselectionEnd
properties modified, like we already do withvalue
andchecked
. Setting these properties to themselves (moving the cursor/selection to where it already is) is idempotent so this should be safe.I've tested this patch by modifying the js output by the compiler.
I've looked through the html spec; there doesn't seem to be other properties being implicitly modified.