From 7d996ec788f06d33e6824354ab8ccb64fd4cd2dd Mon Sep 17 00:00:00 2001 From: addshore Date: Wed, 1 Jun 2016 18:18:48 +0100 Subject: [PATCH] Dont push state to history in cases where not possible This fixes some issues with older versions of IE Bug: T136714 Change-Id: I20d35e16ff4b31c2f719cc72c80ca7c57d5b528e --- modules/ext.RevisionSlider.DiffPage.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/modules/ext.RevisionSlider.DiffPage.js b/modules/ext.RevisionSlider.DiffPage.js index 6c520d6e..aad562af 100644 --- a/modules/ext.RevisionSlider.DiffPage.js +++ b/modules/ext.RevisionSlider.DiffPage.js @@ -41,17 +41,20 @@ }, pushState: function ( revId1, revId2, sliderView ) { - history.pushState( - { - revid1: revId1, - revid2: revId2, - leftPos: sliderView.pointerOne.getPosition(), - rightPos: sliderView.pointerTwo.getPosition(), - sliderPos: sliderView.slider.getFirstVisibleRevisionIndex() - }, - $( document ).find( 'title' ).text(), - mw.util.wikiScript( 'index' ) + '?diff=' + Math.max( revId1, revId2 ) + '&oldid=' + Math.min( revId1, revId2 ) - ); + // IE8 and IE9 do not have history.pushState() + if ( typeof history.pushState === 'function' ) { + history.pushState( + { + revid1: revId1, + revid2: revId2, + leftPos: sliderView.pointerOne.getPosition(), + rightPos: sliderView.pointerTwo.getPosition(), + sliderPos: sliderView.slider.getFirstVisibleRevisionIndex() + }, + $( document ).find( 'title' ).text(), + mw.util.wikiScript( 'index' ) + '?diff=' + Math.max( revId1, revId2 ) + '&oldid=' + Math.min( revId1, revId2 ) + ); + } }, initOnPopState: function ( sliderView ) {