Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Fake selection container was not appended to the new fake selection editable when fake selection changes #1679

Merged
merged 4 commits into from
Feb 19, 2019

Conversation

scofalik
Copy link
Contributor

Suggested merge commit message (convention)

Fix: Fake selection container was not appended to the new fake selection editable when the fake selection changes. Closes ckeditor/ckeditor5#1523.

@scofalik scofalik requested a review from Reinmar February 18, 2019 13:51
@@ -707,7 +707,10 @@ export default class Renderer {
container.appendChild( domDocument.createTextNode( '\u00A0' ) );
}

// Add fake container if not already added.
if ( container.parentElement && container.parentElement != domRoot ) {
Copy link
Contributor Author

@scofalik scofalik Feb 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This if (and below if) could simply be

if ( container.parentElement ) {
    container.remove();
}

domRoot.appendChild( container );

So simpler, but I am not sure if we want to remove and append dom element (container) if there's no need for it. Can it break something? If not, we can go with simpler solution.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd want to avoid moving it around. That may do some strange things to focus. I even considered leaving just one line: domRoot.appendChild( container ); (and no conditions), but I'm afraid what it may do. It depends on how it's implemented internally in the browsers.

However, if you feel braver than I, then you can test it :D

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may feel brave but I also feel lazy.

Copy link
Contributor

@jodator jodator Feb 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICS:

domRoot.appendChild( container );
  1. It works (checked the manual tests for tables & widgets, including inline widgets in tables)
  2. Tests pass
  3. Memory tests for editor-classic passes
  4. No increase in detached DOM nodes (I was worrying that it may happen).

Tested on Chrome only though.

ps.: to be clear:
selection_201

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on Chrome only though.

Which means nothing ;) It has to be tested thoroughly in all browsers. That's why I'd choose the safe path myself.

@coveralls
Copy link

coveralls commented Feb 18, 2019

Coverage Status

Coverage increased (+4.0e-06%) to 99.992% when pulling 8bc959e on t/ckeditor5/1523 into 6577d04 on master.

@Reinmar Reinmar requested review from f1ames, jodator and Mgsy and removed request for f1ames February 18, 2019 15:25
@Reinmar
Copy link
Member

Reinmar commented Feb 18, 2019

@jodator @Mgsy could you take a look at it? Let's make sure it doesn't blow up something.

Copy link
Contributor

@jodator jodator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with or without change proposed @Reinmar.

Would be cool to put focus on it while doing testing phase (assuming @scofalik will not be lazy and change the code as proposed 😛)

@@ -707,7 +707,10 @@ export default class Renderer {
container.appendChild( domDocument.createTextNode( '\u00A0' ) );
}

// Add fake container if not already added.
if ( container.parentElement && container.parentElement != domRoot ) {
Copy link
Contributor

@jodator jodator Feb 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICS:

domRoot.appendChild( container );
  1. It works (checked the manual tests for tables & widgets, including inline widgets in tables)
  2. Tests pass
  3. Memory tests for editor-classic passes
  4. No increase in detached DOM nodes (I was worrying that it may happen).

Tested on Chrome only though.

ps.: to be clear:
selection_201

Copy link
Member

@Mgsy Mgsy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@Reinmar Reinmar merged commit 3b53d5a into master Feb 19, 2019
@Reinmar Reinmar deleted the t/ckeditor5/1523 branch February 19, 2019 10:53
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.

5 participants