Move originalDomElements to IV store and use new hash

Depends-On: I8a71c1a40ec35108d0a9a388da6f75632f8dc53c
Depends-On: I0fbb6324eede94558426178cbdad6b5daf0f8318
Change-Id: I32c9b5f984fcf96e3354841ecfcd444149e8f159
This commit is contained in:
Ed Sanders 2016-08-17 12:52:28 -07:00 committed by Jforrester
parent 8944130bbe
commit fc4788d51b
3 changed files with 7 additions and 10 deletions

View file

@ -184,9 +184,7 @@ QUnit.test( 'newFromDocumentInsertion with references', function ( assert ) {
actualStoreItems = [];
expectedStoreItems = cases[ i ].expectedStoreItems || [];
for ( j = 0; j < expectedStoreItems.length; j++ ) {
actualStoreItems[ j ] = doc.store.value( doc.store.indexOfHash(
OO.getHash( expectedStoreItems[ j ] )
) );
actualStoreItems[ j ] = doc.store.value( OO.getHash( expectedStoreItems[ j ] ) );
}
assert.deepEqual( actualStoreItems, expectedStoreItems, cases[ i ].msg + ': store items' );
}

View file

@ -216,8 +216,8 @@ ve.dm.MWReferenceNode.static.toDomElements = function ( dataElement, doc, conver
el.setAttribute( 'data-mw', originalMw );
// Return the original DOM elements if possible
if ( dataElement.originalDomElements ) {
return ve.copyDomElements( dataElement.originalDomElements, doc );
if ( dataElement.originalDomElementsIndex ) {
return ve.copyDomElements( converter.getStore().value( dataElement.originalDomElementsIndex ), doc );
}
} else {
el.setAttribute( 'data-mw', JSON.stringify( mwData ) );

View file

@ -80,13 +80,11 @@ ve.dm.MWReferencesListNode.static.toDomElements = function ( data, doc, converte
attribs = dataElement.attributes,
contentsData = data.slice( 1, -1 );
if ( dataElement.originalDomElements ) {
if ( dataElement.originalDomElementsIndex ) {
// If there's more than 1 element, preserve entire array, not just first element
els = ve.copyDomElements( dataElement.originalDomElements, doc );
el = els[ 0 ];
els = ve.copyDomElements( converter.getStore().value( dataElement.originalDomElementsIndex ), doc );
} else {
el = doc.createElement( 'div' );
els = [ el ];
els = [ doc.createElement( 'div' ) ];
}
mwData = attribs.mw ? ve.copy( attribs.mw ) : {};
@ -99,6 +97,7 @@ ve.dm.MWReferencesListNode.static.toDomElements = function ( data, doc, converte
delete mwData.attrs.refGroup;
}
el = els[ 0 ];
el.setAttribute( 'typeof', 'mw:Extension/references' );
if ( contentsData.length > 2 ) {