0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2024-12-22 15:23:29 -05:00

Squire: Fix possible error when deleting range

This commit is contained in:
Neil Jenkins 2016-04-07 13:08:45 +10:00
parent d9122222b2
commit 66c0b20702
4 changed files with 11 additions and 3 deletions

View file

@ -361,6 +361,10 @@ function fixCursor ( node, root ) {
} }
} }
if ( node.nodeType === TEXT_NODE ) {
return originalNode;
}
if ( isInline( node ) ) { if ( isInline( node ) ) {
child = node.firstChild; child = node.firstChild;
while ( cantFocusEmptyTextNodes && child && while ( cantFocusEmptyTextNodes && child &&
@ -806,8 +810,8 @@ var deleteContentsOfRange = function ( range, root ) {
moveRangeBoundariesDownTree( range ); moveRangeBoundariesDownTree( range );
// If we split into two different blocks, merge the blocks. // If we split into two different blocks, merge the blocks.
if ( needsMerge ) {
startBlock = getStartBlockOfRange( range, root ); startBlock = getStartBlockOfRange( range, root );
if ( needsMerge ) {
endBlock = getEndBlockOfRange( range, root ); endBlock = getEndBlockOfRange( range, root );
if ( startBlock && endBlock && startBlock !== endBlock ) { if ( startBlock && endBlock && startBlock !== endBlock ) {
mergeWithBlock( startBlock, endBlock, range ); mergeWithBlock( startBlock, endBlock, range );

File diff suppressed because one or more lines are too long

View file

@ -190,6 +190,10 @@ function fixCursor ( node, root ) {
} }
} }
if ( node.nodeType === TEXT_NODE ) {
return originalNode;
}
if ( isInline( node ) ) { if ( isInline( node ) ) {
child = node.firstChild; child = node.firstChild;
while ( cantFocusEmptyTextNodes && child && while ( cantFocusEmptyTextNodes && child &&

View file

@ -153,8 +153,8 @@ var deleteContentsOfRange = function ( range, root ) {
moveRangeBoundariesDownTree( range ); moveRangeBoundariesDownTree( range );
// If we split into two different blocks, merge the blocks. // If we split into two different blocks, merge the blocks.
if ( needsMerge ) {
startBlock = getStartBlockOfRange( range, root ); startBlock = getStartBlockOfRange( range, root );
if ( needsMerge ) {
endBlock = getEndBlockOfRange( range, root ); endBlock = getEndBlockOfRange( range, root );
if ( startBlock && endBlock && startBlock !== endBlock ) { if ( startBlock && endBlock && startBlock !== endBlock ) {
mergeWithBlock( startBlock, endBlock, range ); mergeWithBlock( startBlock, endBlock, range );