0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2025-01-03 05:00:13 -05:00

Fix block boundary issue

If the node is at the end of the document, this method can fail with
'TypeError: Cannot read property 'previousSibling' of null'
This commit is contained in:
Andy Kauffman 2016-05-16 10:08:29 -04:00 committed by Neil Jenkins
parent f7774c8cf3
commit 4e7e290fbc
3 changed files with 9 additions and 1 deletions

View file

@ -1131,6 +1131,10 @@ var rangeDoesStartAtBlockBoundary = function ( range, root ) {
contentWalker.currentNode = startContainer; contentWalker.currentNode = startContainer;
} else { } else {
contentWalker.currentNode = getNodeAfter( startContainer, startOffset ); contentWalker.currentNode = getNodeAfter( startContainer, startOffset );
if ( !contentWalker.currentNode ) {
contentWalker.currentNode = startContainer;
}
} }
// Otherwise, look for any previous content in the same block. // Otherwise, look for any previous content in the same block.

File diff suppressed because one or more lines are too long

View file

@ -472,6 +472,10 @@ var rangeDoesStartAtBlockBoundary = function ( range, root ) {
contentWalker.currentNode = startContainer; contentWalker.currentNode = startContainer;
} else { } else {
contentWalker.currentNode = getNodeAfter( startContainer, startOffset ); contentWalker.currentNode = getNodeAfter( startContainer, startOffset );
if ( !contentWalker.currentNode ) {
contentWalker.currentNode = startContainer;
}
} }
// Otherwise, look for any previous content in the same block. // Otherwise, look for any previous content in the same block.