mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-12 09:09:25 +00:00
Merge "Strip RESTBase IDs from historical diffs"
This commit is contained in:
commit
e657612068
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue