|
|
@@ -3641,6 +3641,48 @@ describe( 'Renderer', () => {
|
|
|
return viewData.repeat( repeat );
|
|
|
}
|
|
|
} );
|
|
|
+
|
|
|
+ // #1782
|
|
|
+ it( 'should leave dom selection untouched while composing', () => {
|
|
|
+ const { view: viewP, selection: newSelection } = parse( '<container:p>[]</container:p>' );
|
|
|
+
|
|
|
+ viewRoot._appendChild( viewP );
|
|
|
+ selection._setTo( newSelection );
|
|
|
+
|
|
|
+ renderer.markToSync( 'children', viewRoot );
|
|
|
+ renderer.render();
|
|
|
+
|
|
|
+ // mock IME typing in Safari: <p>[c]</p>
|
|
|
+ renderer.isComposing = true;
|
|
|
+ const domText = document.createTextNode( 'c' );
|
|
|
+ domRoot.firstChild.appendChild( domText );
|
|
|
+ const range = document.createRange();
|
|
|
+ range.setStart( domText, 0 );
|
|
|
+ range.setEnd( domText, 1 );
|
|
|
+ const domSelection = document.getSelection();
|
|
|
+ domSelection.removeAllRanges();
|
|
|
+ domSelection.addRange( range );
|
|
|
+
|
|
|
+ // <container:p>c[]</container:p>
|
|
|
+ viewP._appendChild( new ViewText( 'c' ) );
|
|
|
+ selection._setTo( [
|
|
|
+ new ViewRange( new ViewPosition( viewP.getChild( 0 ), 1 ), new ViewPosition( viewP.getChild( 0 ), 1 ) )
|
|
|
+ ] );
|
|
|
+
|
|
|
+ renderer.markToSync( 'children', viewP );
|
|
|
+ renderer.render();
|
|
|
+
|
|
|
+ expect( domRoot.childNodes.length ).to.equal( 1 );
|
|
|
+ expect( domRoot.firstChild.childNodes.length ).to.equal( 1 );
|
|
|
+ expect( domRoot.firstChild.firstChild.data ).to.equal( 'c' );
|
|
|
+
|
|
|
+ const currentRange = domSelection.getRangeAt( 0 );
|
|
|
+ expect( currentRange.collapsed ).to.equal( false );
|
|
|
+ expect( currentRange.startContainer ).to.equal( domRoot.firstChild.firstChild );
|
|
|
+ expect( currentRange.startOffset ).to.equal( 0 );
|
|
|
+ expect( currentRange.endContainer ).to.equal( domRoot.firstChild.firstChild );
|
|
|
+ expect( currentRange.endOffset ).to.equal( 1 );
|
|
|
+ } );
|
|
|
} );
|
|
|
|
|
|
describe( '#922', () => {
|