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

Fix error thrown inserting tree fragment at start/end of document.

This commit is contained in:
Neil Jenkins 2015-06-17 15:36:29 +07:00
parent c29a8c639b
commit c25bfe8a9f

View file

@ -250,8 +250,9 @@ var insertTreeFragmentIntoRange = function ( range, frag ) {
nodeBeforeSplit = next.previousSibling;
}
if ( !startContainer.parentNode ) {
startContainer = nodeBeforeSplit;
startOffset = nodeBeforeSplit.childNodes.length;
startContainer = nodeBeforeSplit || next.parentNode;
startOffset = nodeBeforeSplit ?
nodeBeforeSplit.childNodes.length : 0;
}
// Merge inserted containers with edges of split
if ( isContainer( next ) ) {
@ -277,7 +278,7 @@ var insertTreeFragmentIntoRange = function ( range, frag ) {
endOffset = prev.childNodes.length;
}
// Merge inserted containers with edges of split
if ( isContainer( nodeAfterSplit ) ) {
if ( nodeAfterSplit && isContainer( nodeAfterSplit ) ) {
mergeContainers( nodeAfterSplit );
}