This repository has been archived by the owner on Jun 26, 2020. It is now read-only.
Fixed view.Renderer
bug causing editor crash in some scenarios involving reusing DOM elements
#1828
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.
Suggested merge commit message (convention)
Fix: Fixed
view.Renderer
bug causing editor crash in some scenarios involving reusing DOM elements. Closes ckeditor/ckeditor5#6092.Additional information
To fix the issue, I inverted the order in which the actions in
_updateChildren()
happen. Earlier, after getting a diff, actions were performed one after another, as indiff
array. I've changed it, so now deletions are performed first and insertions later. This prevents the situation where we are inserting a child which is still in that parent (as described in the ticket).There was an alternative solution, where instead I did
Array.from()
onactualDomChildren
and then was updatingactualDomChildren
in thediff
loop and then when delete action was handled, I was checking if the element was already inactualDomChildren
.I think that the solution from PR is safer, though.
I've added only one unit test to confirm that the solution is working. The test is a scenario described in ckeditor/ckeditor5#6367. It tests exactly the described problem, that is, moving a DOM element "back".
The umbrella issue mentions a couple of issues.
I've tested:
I haven't tested:
TODO: