mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 07:13:08 -05:00
Always restore range to textnodes.
When restoring a range from a bookmark, always call range.moveBoundariesDownTree to anchor it to the nearest text node. If you call setSelection with a range not anchored inside a textnode, Opera may incorrectly set the selection.
This commit is contained in:
parent
ffd6edbaef
commit
819ddb296e
2 changed files with 8 additions and 5 deletions
File diff suppressed because one or more lines are too long
|
@ -325,7 +325,8 @@
|
|||
|
||||
if ( start && end ) {
|
||||
var startContainer = start.parentNode,
|
||||
endContainer = end.parentNode;
|
||||
endContainer = end.parentNode,
|
||||
collapsed;
|
||||
|
||||
var _range = {
|
||||
startContainer: startContainer,
|
||||
|
@ -352,9 +353,11 @@
|
|||
}
|
||||
range.setStart( _range.startContainer, _range.startOffset );
|
||||
range.setEnd( _range.endContainer, _range.endOffset );
|
||||
|
||||
if ( !range.collapsed ) {
|
||||
range.moveBoundariesDownTree();
|
||||
collapsed = range.collapsed;
|
||||
|
||||
range.moveBoundariesDownTree();
|
||||
if ( collapsed ) {
|
||||
range.collapse( true );
|
||||
}
|
||||
}
|
||||
return range;
|
||||
|
|
Loading…
Reference in a new issue