From c9b5d1faf151e5082ed9162a4fbd04e485388019 Mon Sep 17 00:00:00 2001 From: Michael Cox Date: Wed, 4 Nov 2015 18:55:17 +0000 Subject: [PATCH] Add option to disable pushState --- index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/index.js b/index.js index b228daf1..3e724fab 100755 --- a/index.js +++ b/index.js @@ -39,6 +39,11 @@ */ var decodeURLComponents = true; + /** + * Handle pushState + */ + var handlePushState = true; + /** * Base path. */ @@ -158,6 +163,7 @@ running = true; if (false === options.dispatch) dispatch = false; if (false === options.decodeURLComponents) decodeURLComponents = false; + if (false === options.handlePushState) handlePushState = false; if (false !== options.popstate) window.addEventListener('popstate', onpopstate, false); if (false !== options.click) { document.addEventListener(clickEvent, onclick, false); @@ -416,6 +422,7 @@ Context.prototype.pushState = function() { page.len++; + if (!handlePushState) return; history.pushState(this.state, this.title, hashbang && this.path !== '/' ? '#!' + this.path : this.canonicalPath); };