@@ -567,35 +567,42 @@ export default class Renderer {
567567 */
568568 _updateFakeSelection ( domRoot ) {
569569 const domDocument = domRoot . ownerDocument ;
570+ let container = this . _fakeSelectionContainer ;
570571
571572 // Create fake selection container if one does not exist.
572- if ( ! this . _fakeSelectionContainer ) {
573- this . _fakeSelectionContainer = domDocument . createElement ( 'div' ) ;
574- this . _fakeSelectionContainer . style . position = 'fixed' ;
575- this . _fakeSelectionContainer . style . top = 0 ;
576- this . _fakeSelectionContainer . style . left = '-9999px' ;
577- this . _fakeSelectionContainer . appendChild ( domDocument . createTextNode ( '\u00A0' ) ) ;
573+ if ( ! container ) {
574+ this . _fakeSelectionContainer = container = domDocument . createElement ( 'div' ) ;
575+
576+ Object . assign ( container . style , {
577+ position : 'fixed' ,
578+ top : 0 ,
579+ left : '-9999px' ,
580+ // See https://github.com/ckeditor/ckeditor5/issues/752.
581+ width : '42px'
582+ } ) ;
583+
584+ // Fill it with a text node so we can update it later.
585+ container . appendChild ( domDocument . createTextNode ( '\u00A0' ) ) ;
578586 }
579587
580588 // Add fake container if not already added.
581- if ( ! this . _fakeSelectionContainer . parentElement ) {
582- domRoot . appendChild ( this . _fakeSelectionContainer ) ;
589+ if ( ! container . parentElement ) {
590+ domRoot . appendChild ( container ) ;
583591 }
584592
585593 // Update contents.
586- const content = this . selection . fakeSelectionLabel || '\u00A0' ;
587- this . _fakeSelectionContainer . firstChild . data = content ;
594+ container . firstChild . data = this . selection . fakeSelectionLabel || '\u00A0' ;
588595
589596 // Update selection.
590597 const domSelection = domDocument . getSelection ( ) ;
591- domSelection . removeAllRanges ( ) ;
592-
593598 const domRange = domDocument . createRange ( ) ;
594- domRange . selectNodeContents ( this . _fakeSelectionContainer ) ;
599+
600+ domSelection . removeAllRanges ( ) ;
601+ domRange . selectNodeContents ( container ) ;
595602 domSelection . addRange ( domRange ) ;
596603
597604 // Bind fake selection container with current selection.
598- this . domConverter . bindFakeSelection ( this . _fakeSelectionContainer , this . selection ) ;
605+ this . domConverter . bindFakeSelection ( container , this . selection ) ;
599606 }
600607
601608 /**
0 commit comments