|
@@ -1958,6 +1958,31 @@ describe( 'Renderer', () => {
|
|
|
expect( bindSelection.isEqual( selection ) ).to.be.true;
|
|
expect( bindSelection.isEqual( selection ) ).to.be.true;
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
|
|
+ // https://github.com/ckeditor/ckeditor5-engine/issues/1714.
|
|
|
|
|
+ it( 'should handle situation when label got removed from the fake selection container', () => {
|
|
|
|
|
+ const label = 'fake selection label';
|
|
|
|
|
+ selection._setTo( selection.getRanges(), { fake: true, label } );
|
|
|
|
|
+ renderer.render();
|
|
|
|
|
+
|
|
|
|
|
+ expect( domRoot.childNodes.length ).to.equal( 2 );
|
|
|
|
|
+
|
|
|
|
|
+ const container = domRoot.childNodes[ 1 ];
|
|
|
|
|
+ expect( domConverter.mapDomToView( container ) ).to.be.undefined;
|
|
|
|
|
+ expect( container.childNodes.length ).to.equal( 1 );
|
|
|
|
|
+
|
|
|
|
|
+ const textNode = container.childNodes[ 0 ];
|
|
|
|
|
+ expect( textNode.textContent ).to.equal( label );
|
|
|
|
|
+
|
|
|
|
|
+ // Remove a text node (label) from the fake selection container.
|
|
|
|
|
+ // It can be done by pressing backspace while the delete command is disabled and selection is on the widget.
|
|
|
|
|
+ textNode.remove();
|
|
|
|
|
+
|
|
|
|
|
+ renderer.render();
|
|
|
|
|
+
|
|
|
|
|
+ const domSelection = domRoot.ownerDocument.getSelection();
|
|
|
|
|
+ assertDomSelectionContents( domSelection, container, /^fake selection label$/ );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
// Use a forgiving way of checking what the selection contains
|
|
// Use a forgiving way of checking what the selection contains
|
|
|
// because Safari normalizes the selection ranges so precise checking is troublesome.
|
|
// because Safari normalizes the selection ranges so precise checking is troublesome.
|
|
|
// Also, Edge returns a normal space instead of nbsp so we need to use even more alternatives.
|
|
// Also, Edge returns a normal space instead of nbsp so we need to use even more alternatives.
|