Merge "Fix section param in historical diffs"

This commit is contained in:
jenkins-bot 2019-03-09 01:14:40 +00:00 committed by Gerrit Code Review
commit 73063b4f8c
3 changed files with 13 additions and 10 deletions

View file

@ -1075,7 +1075,7 @@ ve.init.mw.ArticleTarget.prototype.getVisualDiffGeneratorPromise = function () {
// re-fetch the HTML
target.originalDmDocPromise = $.Deferred().resolve( target.constructor.static.createModelFromDom( target.doc, 'visual' ) ).promise();
} else {
target.originalDmDocPromise = mw.libs.ve.diffLoader.fetchRevision( target.revid, target.getPageName(), undefined, target.section !== null ? target.section : undefined );
target.originalDmDocPromise = mw.libs.ve.diffLoader.fetchRevision( target.revid, target.getPageName(), target.section );
}
}

View file

@ -22,7 +22,7 @@
* Get a ve.dm.Document model from a Parsoid response
*
* @param {Object} response Parsoid response from the VisualEditor API
* @param {number} [section] Section
* @param {number|null} section Section. Null for the whole document.
* @return {ve.dm.Document|null} Document, or null if an invalid response
*/
getModelFromResponse: function ( response, section ) {
@ -31,7 +31,7 @@
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', section, true );
doc = targetClass.static.parseDocument( data.content, 'visual', section, section !== null );
// Strip RESTBase IDs
Array.prototype.forEach.call( doc.querySelectorAll( '[id^="mw"]' ), function ( element ) {
if ( element.id.match( metadataIdRegExp ) ) {
@ -48,15 +48,18 @@
*
* @param {number} revId Revision ID
* @param {string} [pageName] Page name, defaults to wgRelevantPageName
* @param {number|null} [section=null] Section. Null for the whole document.
* @param {jQuery.Promise} [parseDocumentModulePromise] Promise which resolves when Target#parseDocument is available
* @param {number} [section] Section
* @return {jQuery.Promise} Promise which resolves with a document model
*/
fetchRevision: function ( revId, pageName, parseDocumentModulePromise, section ) {
var cacheKey = revId + ( section !== undefined ? '/' + section : '' );
fetchRevision: function ( revId, pageName, section, parseDocumentModulePromise ) {
var cacheKey;
parseDocumentModulePromise = parseDocumentModulePromise || $.Deferred().resolve().promise();
pageName = pageName || mw.config.get( 'wgRelevantPageName' );
parseDocumentModulePromise = parseDocumentModulePromise || $.Deferred().resolve().promise();
section = section !== undefined ? section : null;
cacheKey = revId + ( section !== null ? '/' + section : '' );
revCache[ cacheKey ] = revCache[ cacheKey ] ||
mw.libs.ve.targetLoader.requestParsoidData( pageName, { oldId: revId, targetName: 'diff' } ).then( function ( response ) {
@ -84,8 +87,8 @@
parseDocumentModulePromise = parseDocumentModulePromise || $.Deferred().resolve().promise();
oldPageName = oldPageName || mw.config.get( 'wgRelevantPageName' );
oldRevPromise = typeof oldIdOrPromise === 'number' ? this.fetchRevision( oldIdOrPromise, oldPageName, parseDocumentModulePromise ) : oldIdOrPromise;
newRevPromise = typeof newIdOrPromise === 'number' ? this.fetchRevision( newIdOrPromise, newPageName, parseDocumentModulePromise ) : newIdOrPromise;
oldRevPromise = typeof oldIdOrPromise === 'number' ? this.fetchRevision( oldIdOrPromise, oldPageName, null, parseDocumentModulePromise ) : oldIdOrPromise;
newRevPromise = typeof newIdOrPromise === 'number' ? this.fetchRevision( newIdOrPromise, newPageName, null, parseDocumentModulePromise ) : newIdOrPromise;
return $.when( oldRevPromise, newRevPromise, parseDocumentModulePromise ).then( function ( oldDoc, newDoc ) {
// TODO: Differ expects newDoc to be derived from oldDoc and contain all its store data.

View file

@ -178,7 +178,7 @@ ve.init.mw.Target.prototype.createModelFromDom = function () {
/**
* @inheritdoc
* @param {number|string|null} section Section
* @param {number|string|null} section Section. Use null to unwrap all sections.
* @param {boolean} [onlySection] Only return the requested section, otherwise returns the
* whole document with just the requested section still wrapped (visual mode only).
*/