Bläddra i källkod

Refactor the check function meaning in tablecell-post-fixer.

Maciej Gołaszewski 7 år sedan
förälder
incheckning
2b3c5ec956
1 ändrade filer med 3 tillägg och 3 borttagningar
  1. 3 3
      packages/ckeditor5-table/src/converters/tablecell-post-fixer.js

+ 3 - 3
packages/ckeditor5-table/src/converters/tablecell-post-fixer.js

@@ -91,7 +91,7 @@ function tableCellPostFixer( writer, model, mapper, view ) {
 	// Selection in the view might not be updated to renamed elements. Happens mostly when other feature inserts paragraph to the table cell
 	// (ie. when deleting table cell contents) and sets selection to it while table-post fixer changes view <p> to <span> element.
 	// The view.selection would have outdated nodes.
-	if ( wasFixed && !isSelectionValid( view.document.selection, mapper ) ) {
+	if ( wasFixed && selectionNeedsFix( view.document.selection, mapper ) ) {
 		updateRangesInViewSelection( model.document.selection, mapper, writer );
 	}
 
@@ -184,9 +184,9 @@ function updateRangesInViewSelection( selection, mapper, writer ) {
 // Checks if selection needs to be fixed by ensuring that current view selection position's parents are present in the editable view.
 //
 // @param {module:engine/view/selection~Selection} viewSelection
-function isSelectionValid( viewSelection ) {
+function selectionNeedsFix( viewSelection ) {
 	const anchor = viewSelection.anchor;
 	const focus = viewSelection.focus;
 
-	return viewSelection.rangeCount && anchor.root.is( 'rootElement' ) && focus.root.is( 'rootElement' );
+	return viewSelection.rangeCount && ( !anchor.root.is( 'rootElement' ) || !focus.root.is( 'rootElement' ) );
 }