Skip to content
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

Merged
merged 3 commits into from
Mar 4, 2020

Conversation

scofalik
Copy link
Contributor

@scofalik scofalik commented Mar 3, 2020

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 in diff 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() on actualDomChildren and then was updating actualDomChildren in the diff loop and then when delete action was handled, I was checking if the element was already in actualDomChildren.

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:

  1. Please confirm that the fix works. It would be a good idea to try to test the cases I haven't checked.
  2. Write more unit tests that would focus on the cases described in those issues.

@coveralls
Copy link

coveralls commented Mar 3, 2020

Coverage Status

Coverage remained the same at 100.0% when pulling 91f95ba on i/6092 into 3564ce5 on master.

@Reinmar Reinmar merged commit 67884da into master Mar 4, 2020
@Reinmar Reinmar deleted the i/6092 branch March 4, 2020 19:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Weird renderer bug: Cannot read property 'parentNode' of undefined
3 participants