code: function fixRangesAfterHiddenSelectionContainer( ranges, root ) {
  		var range;
  		for ( var i = 0; i < ranges.length; ++i ) {
  			range = ranges[ i ];
  			if ( range.endContainer.equals( root ) ) {
  				// We can use getChildCount() because hidden selection container is not in DOM.
  				range.endOffset = Math.min( range.endOffset, root.getChildCount() );
  			}
  		}
  	}
docs: Fix ranges which may end after hidden selection container. Note: this function may only be used if hidden selection container is not in DOM any more.