Make data-mw/body.html attribute comparable

Change-Id: Ie23c5816a18f4da84c3d40c13a8c048710389f4b
This commit is contained in:
Ed Sanders 2015-09-24 16:37:21 +01:00
parent 0f6bdb9071
commit 6a159001ab

View file

@ -75,3 +75,30 @@ ve.test.utils.mwEnvironment = ( function () {
teardown: teardownOverrides
} );
} )();
( function () {
var getDomElementSummaryCore = ve.getDomElementSummary;
/**
* Override getDomElementSummary to extract HTML from data-mw/body.html
* and make it comparable.
*
* @method
* @inheritdoc ve#getDomElementSummary
*/
ve.getDomElementSummary = function ( element, includeHtml ) {
// "Parent" method
return getDomElementSummaryCore( element, includeHtml, function ( name, value ) {
var obj, html;
if ( name === 'data-mw' ) {
obj = JSON.parse( value );
html = ve.getProp( obj, 'body', 'html' );
if ( html ) {
obj.body.html = ve.getDomElementSummary( $( '<div>' ).html( html )[ 0 ] );
}
return obj;
}
return value;
} );
};
} )();