From 26726ee31d46f369a9e973cd1219d9f845e93187 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Sat, 9 Nov 2013 12:23:17 +0000 Subject: [PATCH] Fix edit source switch in Firefox Previously was failing for two reasons: 1. FF requires the form to be attached before submitting 2. options.watch failed because of FF's annoying Object.prototype.watch Bug: 56767 Change-Id: I7b3d349f057f5b87f823ce788b4143f817af5303 --- .../ve-mw/init/targets/ve.init.mw.ViewPageTarget.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js index a2b94dbf15..1ea1d1edb4 100644 --- a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js +++ b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js @@ -855,12 +855,13 @@ ve.init.mw.ViewPageTarget.prototype.editSource = function () { this.serialize( ve.dm.converter.getDomFromData( doc.getFullData(), doc.getStore(), doc.getInternalList() ), ve.bind( function ( wikitext ) { - var options = this.getSaveOptions(), + var $form, + options = this.getSaveOptions(), action = new mw.Uri( mw.util.wikiScript() ).extend( { title: this.pageName, action: 'edit' } ).toString(); this.submitting = true; - $( '
' ) + $form = $( '
' ) .attr( 'action', action ) .append( $( '' ).val( wikitext ) ) .append( $( '' ).prop( 'checked', options.minor ) ) @@ -872,8 +873,10 @@ ve.init.mw.ViewPageTarget.prototype.editSource = function () { .append( $( '' ) ) .append( $( '' ) ) .append( $( '' ) ) - .submit() ; + // Firefox requires the form to be attached + $( 'body' ).append( $form ); + $form.submit(); }, this ) ); }; @@ -914,6 +917,9 @@ ve.init.mw.ViewPageTarget.prototype.getSaveOptions = function () { } if ( this.saveDialog.$saveOptions.find( '#wpWatchthis' ).prop( 'checked' ) ) { options.watch = 1; + } else { + // Firefox has Object.prototype.watch + options.watch = undefined; } this.saveDialog.$saveOptions .find( '.ve-ui-mwSaveDialog-checkboxes' )