Resolve URLs in show preview against correct base

Bug: T153277
Change-Id: Icaa6de4618de008fb2024d1dd428114688cb1043
This commit is contained in:
Ed Sanders 2016-12-15 02:55:26 +00:00 committed by Catrope
parent c92418e4da
commit 9728d78126
2 changed files with 10 additions and 4 deletions

View file

@ -1007,12 +1007,18 @@ ve.init.mw.ArticleTarget.prototype.onSaveDialogPreview = function () {
wikitext: wikitext,
pst: true
} ).always( function ( response, details ) {
var doc, body;
if ( ve.getProp( response, 'visualeditor', 'result' ) === 'success' ) {
target.saveDialog.showPreview( response.visualeditor.content );
doc = target.parseDocument( response.visualeditor.content, 'visual' );
body = doc.body;
// Import body to current document, then resolve attributes against original document (parseDocument called #fixBase)
document.adoptNode( body );
ve.resolveAttributes( body, doc, ve.dm.Converter.static.computedAttributes );
target.saveDialog.showPreview( $( body ).contents() );
} else {
target.saveDialog.showPreview( $( '<em>' ).text(
ve.msg( 'visualeditor-loaderror-message', ve.getProp( details, 'error', 'info' ) || 'Failed to connect' )
).html() );
) );
}
target.bindSaveDialogClearDiff();
} );

View file

@ -127,10 +127,10 @@ ve.ui.MWSaveDialog.prototype.setDiffAndReview = function ( content ) {
/**
* Set preview content and show preview panel.
*
* @param {string} content Preview HTML
* @param {jQuery} content Preview content
*/
ve.ui.MWSaveDialog.prototype.showPreview = function ( content ) {
this.$previewViewer.html( content );
this.$previewViewer.empty().append( content );
mw.hook( 'wikipage.content' ).fire( this.$previewViewer );
this.actions.setAbilities( { approve: true } );
this.popPending();