Merge "Fix JS error in DocumentSynchronizer when adding to an empty document"

This commit is contained in:
Trevor Parscal 2012-10-17 19:28:58 +00:00 committed by Gerrit Code Review
commit 64442e03d8

View file

@ -112,10 +112,12 @@ ve.dm.DocumentSynchronizer.synchronizers.rebuild = function ( action ) {
return;
}
if ( 'indexInNode' in selection[0] ) {
// If the document is empty, selection[0].node will be the document (so no parent)
// but we won't get indexInNode either. Detect this and use index=0 in that case.
if ( 'indexInNode' in selection[0] || !selection[0].node.getParent() ) {
// Insertion
parent = selection[0].node;
index = selection[0].indexInNode;
index = selection[0].indexInNode || 0;
numNodes = 0;
} else {
// Rebuild