mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 15:23:29 -05:00
[Issue-147] Fix Firefox hidden iframe win.getSelection() bug
[Issue-147] Fixed code convention errors
This commit is contained in:
parent
9461368a5c
commit
08e85c912b
1 changed files with 11 additions and 6 deletions
|
@ -39,7 +39,6 @@ function Squire ( doc, config ) {
|
||||||
|
|
||||||
this._events = {};
|
this._events = {};
|
||||||
|
|
||||||
this._sel = win.getSelection();
|
|
||||||
this._lastSelection = null;
|
this._lastSelection = null;
|
||||||
|
|
||||||
// IE loses selection state of iframe on blur, so make sure we
|
// IE loses selection state of iframe on blur, so make sure we
|
||||||
|
@ -325,17 +324,23 @@ proto.setSelection = function ( range ) {
|
||||||
if ( isIOS ) {
|
if ( isIOS ) {
|
||||||
this._win.focus();
|
this._win.focus();
|
||||||
}
|
}
|
||||||
var sel = this._sel;
|
var sel = this._getWindowSelection();
|
||||||
|
if ( sel ) {
|
||||||
sel.removeAllRanges();
|
sel.removeAllRanges();
|
||||||
sel.addRange( range );
|
sel.addRange( range );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
proto._getWindowSelection = function () {
|
||||||
|
return this._win.getSelection() || null;
|
||||||
|
};
|
||||||
|
|
||||||
proto.getSelection = function () {
|
proto.getSelection = function () {
|
||||||
var sel = this._sel,
|
var sel = this._getWindowSelection(),
|
||||||
selection, startContainer, endContainer;
|
selection, startContainer, endContainer;
|
||||||
if ( sel.rangeCount ) {
|
if ( sel && sel.rangeCount ) {
|
||||||
selection = sel.getRangeAt( 0 ).cloneRange();
|
selection = sel.getRangeAt( 0 ).cloneRange();
|
||||||
startContainer = selection.startContainer;
|
startContainer = selection.startContainer;
|
||||||
endContainer = selection.endContainer;
|
endContainer = selection.endContainer;
|
||||||
|
|
Loading…
Reference in a new issue