Strip RESTBase IDs from historical diffs

Change-Id: I911d529204a97003ed233464709737b018918634
This commit is contained in:
Ed Sanders 2017-09-14 13:45:10 +01:00
parent 1809344c8a
commit 405afdce70

View file

@ -27,9 +27,16 @@
getModelFromResponse: function ( response ) {
var doc,
targetClass = ve.init.mw.DesktopArticleTarget,
metadataIdRegExp = ve.init.platform.getMetadataIdRegExp(),
data = response ? ( response.visualeditor || response.visualeditoredit ) : null;
if ( data && typeof data.content === 'string' ) {
doc = targetClass.static.parseDocument( data.content, 'visual' );
// Strip RESTBase IDs
Array.prototype.forEach.call( doc.querySelectorAll( '[id^="mw"]' ), function ( element ) {
if ( element.id.match( metadataIdRegExp ) ) {
element.removeAttribute( 'id' );
}
} );
return targetClass.static.createModelFromDom( doc, 'visual' );
}
return null;