mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 07:13:08 -05:00
Fix IE returns null for getSelection if never focussed.
This commit is contained in:
parent
52a10d463c
commit
f9974ed7d9
4 changed files with 11 additions and 8 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -167,7 +167,7 @@
|
|||
return lastSelection;
|
||||
};
|
||||
|
||||
// IE9 loses selection state of iframe on blur, so make sure we
|
||||
// IE loses selection state of iframe on blur, so make sure we
|
||||
// cache it just before it loses focus.
|
||||
if ( losesSelectionOnBlur ) {
|
||||
win.addEventListener( 'beforedeactivate', getSelection, true );
|
||||
|
@ -1761,10 +1761,13 @@
|
|||
var range = createRange( body.firstChild, 0 );
|
||||
recordUndoState( range );
|
||||
getRangeAndRemoveBookmark( range );
|
||||
// IE8 will also set focus when selecting text.
|
||||
// It doesn't make any difference since it doesn't
|
||||
// maintain selection when not focussed anyway.
|
||||
if ( !isIE8 ) {
|
||||
// IE will also set focus when selecting text so don't use
|
||||
// setSelection. Instead, just store it in lastSelection, so if
|
||||
// anything calls getSelection before first focus, we have a range
|
||||
// to return.
|
||||
if ( losesSelectionOnBlur ) {
|
||||
lastSelection = range;
|
||||
} else {
|
||||
setSelection( range );
|
||||
}
|
||||
updatePath( range, true );
|
||||
|
|
|
@ -452,7 +452,7 @@ var toTextRange = function ( range ) {
|
|||
};
|
||||
|
||||
var selection = {
|
||||
rangeCount: 1,
|
||||
rangeCount: 0,
|
||||
getRangeAt: function ( index ) {
|
||||
if ( index !== 0 ) { return undefined; }
|
||||
var sel = document.selection.createRange();
|
||||
|
|
Loading…
Reference in a new issue