From 5ec0ce09e12ef689a912b5a9306b802753eb0533 Mon Sep 17 00:00:00 2001 From: Behind The Math Date: Mon, 29 Jan 2018 23:57:18 -0500 Subject: [PATCH] Remove old switchFallback code --- README.md | 5 ++--- index.js | 18 ------------------ lib/proto/parse-options.js | 7 +++---- 3 files changed, 5 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index debf522..116cadc 100644 --- a/README.md +++ b/README.md @@ -394,8 +394,7 @@ in order to skip browser cache. ##### `debug` (Boolean, default: `false`) -Enables verbose mode & doesn't use fallback when there is an error. -Useful to debug page layout differences. +Enables verbose mode. Useful to debug page layout differences. ##### `currentUrlFullReload` (Boolean, default: `false`) @@ -416,7 +415,7 @@ All events are fired from the _document_, not the link that was clicked. * `pjax:send` - Fired after the Pjax request begins. * `pjax:complete` - Fired after the Pjax request finishes. * `pjax:success` - Fired after the Pjax request succeeds. -* `pjax:error` - Fired after the Pjax request fails. Returning false will prevent the the fallback redirect. +* `pjax:error` - Fired after the Pjax request fails. `send` and `complete` are a good pair of events to use if you are implementing a loading indicator (eg: [topbar](http://buunguyen.github.io/topbar/)) diff --git a/index.js b/index.js index 61bf465..7d20baa 100644 --- a/index.js +++ b/index.js @@ -81,15 +81,6 @@ Pjax.prototype = { return require("./lib/switches-selectors.js").bind(this)(this.options.switches, this.options.switchesOptions, selectors, fromEl, toEl, options) }, - // too much problem with the code below - // + it’s too dangerous - // switchFallback: function(fromEl, toEl) { - // this.switchSelectors(["head", "body"], fromEl, toEl) - // // execute script when DOM is like it should be - // Pjax.executeScripts(document.querySelector("head")) - // Pjax.executeScripts(document.querySelector("body")) - // } - latestChance: function(href) { window.location = href }, @@ -139,16 +130,7 @@ Pjax.prototype = { } catch (e) { } } - // try { this.switchSelectors(this.options.selectors, tmpEl, document, options) - - // } - // catch(e) { - // if (this.options.debug) { - // this.log("Pjax switch fail: ", e) - // } - // this.switchFallback(tmpEl, document) - // } }, abortRequest: require("./lib/abort-request.js"), diff --git a/lib/proto/parse-options.js b/lib/proto/parse-options.js index 6c35d0d..b770d85 100644 --- a/lib/proto/parse-options.js +++ b/lib/proto/parse-options.js @@ -25,10 +25,9 @@ module.exports = function(options) { options.debug = options.debug || false options.timeout = options.timeout || 0 - // we can’t replace body.outerHTML or head.outerHTML - // it create a bug where new body or new head are created in the dom - // if you set head.outerHTML, a new body tag is appended, so the dom get 2 body - // & it break the switchFallback which replace head & body + // We can’t replace body.outerHTML or head.outerHTML. + // It creates a bug where a new body or head are created in the DOM. + // If you set head.outerHTML, a new body tag is appended, so the DOM has 2 body nodes, and vice versa if (!options.switches.head) { options.switches.head = defaultSwitches.switchElementsAlt }