mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-28 16:20:52 +00:00
Merge "Fix JS error in DocumentSynchronizer when adding to an empty document"
This commit is contained in:
commit
64442e03d8
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue