mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 07:13:08 -05:00
FF: Selection range may not have startContainer.
* Odd bug this. From the logs, it seems either it's returning a range with no startContainer, or the startContainer is not something inheriting from the Node prototype (which would be very wrong).
This commit is contained in:
parent
a069e8305e
commit
5b52e9b4b8
2 changed files with 7 additions and 5 deletions
File diff suppressed because one or more lines are too long
|
@ -160,12 +160,14 @@
|
|||
var getSelection = function () {
|
||||
if ( sel.rangeCount ) {
|
||||
lastSelection = sel.getRangeAt( 0 ).cloneRange();
|
||||
var startContainer = lastSelection.startContainer,
|
||||
endContainer = lastSelection.endContainer;
|
||||
// FF can return the selection as being inside an <img>. WTF?
|
||||
if ( lastSelection.startContainer.isLeaf() ) {
|
||||
lastSelection.setStartBefore( lastSelection.startContainer );
|
||||
if ( startContainer && startContainer.isLeaf() ) {
|
||||
lastSelection.setStartBefore( startContainer );
|
||||
}
|
||||
if ( lastSelection.endContainer.isLeaf() ) {
|
||||
lastSelection.setEndBefore( lastSelection.endContainer );
|
||||
if ( endContainer && endContainer.isLeaf() ) {
|
||||
lastSelection.setEndBefore( endContainer );
|
||||
}
|
||||
}
|
||||
return lastSelection;
|
||||
|
|
Loading…
Reference in a new issue