Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit 9b5ae16

Browse files
committed
support disabling pushstate with option
1 parent fbd7288 commit 9b5ae16

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

js/navigation/events/navigate.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ define([ "jquery",
1818

1919
originalEventName: undefined,
2020

21+
isPushStateEnabled: function() {
22+
return $.support.pushState && $.mobile && $.mobile.pushStateEnabled;
23+
},
24+
2125
// TODO a lot of duplication between popstate and hashchange
2226
popstate: function( event ) {
2327
var newEvent = new $.Event( "navigate" ),
@@ -86,7 +90,7 @@ define([ "jquery",
8690

8791
self.bound = true;
8892

89-
if( $.support.pushState && self.pushStateEnabled ) {
93+
if( self.isPushStateEnabled() ) {
9094
self.originalEventName = "popstate";
9195
$win.bind( "popstate.navigate", self.popstate );
9296
} else {

js/navigation/navigate.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ define([
1111
//>>excludeEnd("jqmBuildExclude");
1212

1313
(function( $, undefined ) {
14-
var path = $.mobile.path, history, popstateEvent;
14+
var path = $.mobile.path, history;
1515

1616
// TODO consider queueing navigation activity until previous activities have completed
1717
// so that end users don't have to think about it. Punting for now
1818
// TODO !! move the event bindings into callbacks on the navigate event
1919
$.navigate = function( url, data, noEvents ) {
20-
var state, href, parsed, loc, hash,
20+
var state, href, parsed, loc, hash, popstateEvent,
2121
resolutionUrl = path.isPath( url ) ? path.getLocation() : $.mobile.getDocumentUrl();
2222

2323
// Get the url as it would look squashed on to the current resolution url
@@ -69,7 +69,7 @@ define([
6969
title: document.title
7070
}, data);
7171

72-
if( $.support.pushState ) {
72+
if( $.event.special.navigate.isPushStateEnabled() ) {
7373
popstateEvent = new $.Event( "popstate" );
7474
popstateEvent.originalEvent = {
7575
type: "popstate",
@@ -134,7 +134,7 @@ define([
134134

135135
// Partly to support our test suite which manually alters the support
136136
// value to test hashchange. Partly to prevent all around weirdness
137-
if( !$.support.pushState ){
137+
if( !$.event.special.navigate.isPushStateEnabled() ){
138138
return;
139139
}
140140

@@ -211,7 +211,7 @@ define([
211211

212212
// If pushstate is supported the state will be included in the popstate event
213213
// data and appended to the navigate event. Late check here for late settings (eg tests)
214-
if( $.support.pushState ) {
214+
if( $.event.special.navigate.isPushStateEnabled() ) {
215215
return;
216216
}
217217

0 commit comments

Comments
 (0)