0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2024-12-22 15:23:29 -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:
Neil Jenkins 2012-06-19 14:35:44 +10:00
parent ffd6edbaef
commit 819ddb296e
2 changed files with 8 additions and 5 deletions

File diff suppressed because one or more lines are too long

View file

@ -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;