mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 18:39:52 +00:00
Fix history.replaceState call on diff pages
The history.replaceState call in onReviewModeButtonSelectSelect() (1) ignores any changes to the document URL made by external tools such as RevisionSlider, (2) replaces with an empty string the history entry state object if it was set by external tools such as, again, RevisionSlider. Both 1 and 2 result in a wrong URL ending up in the address bar at some point. This patch addresses these problems, (1) creating a new mw.Uri() object every time onReviewModeButtonSelectSelect() is called, (2) keeping the current history.state object. The original variable storing the URI object is renamed to avoid shadowing (optionally can be replaced with its value as it's used only once). Bug: T288636 Change-Id: Ieb97b561a6c076aa28aae231fe286ac4d1051bbd
This commit is contained in:
parent
4c969911d3
commit
6d7a062dbb
|
@ -13,8 +13,8 @@
|
|||
$visualDiffContainer = $( '<div>' ),
|
||||
$visualDiff = $( '<div>' ),
|
||||
progress = new OO.ui.ProgressBarWidget( { classes: [ 've-init-mw-diffPage-loading' ] } ),
|
||||
uri = new mw.Uri(),
|
||||
mode = uri.query.diffmode || mw.user.options.get( 'visualeditor-diffmode-historical' ) || 'source',
|
||||
originalUri = new mw.Uri(),
|
||||
mode = originalUri.query.diffmode || mw.user.options.get( 'visualeditor-diffmode-historical' ) || 'source',
|
||||
conf = mw.config.get( 'wgVisualEditorConfig' ),
|
||||
pluginModules = conf.pluginModules.filter( mw.loader.getState );
|
||||
|
||||
|
@ -31,7 +31,8 @@
|
|||
function onReviewModeButtonSelectSelect( item ) {
|
||||
var $revSlider = $( '.mw-revslider-container' ),
|
||||
oldId = mw.config.get( 'wgDiffOldId' ),
|
||||
newId = mw.config.get( 'wgDiffNewId' );
|
||||
newId = mw.config.get( 'wgDiffNewId' ),
|
||||
uri = new mw.Uri();
|
||||
|
||||
var oldPageName, newPageName;
|
||||
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) !== 'ComparePages' ) {
|
||||
|
@ -92,7 +93,7 @@
|
|||
|
||||
if ( history.replaceState ) {
|
||||
uri.query.diffmode = mode;
|
||||
history.replaceState( '', document.title, uri );
|
||||
history.replaceState( history.state, document.title, uri );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue