Code cleanup #120

Merged
BehindTheMath merged 13 commits from cleanup/misc-cleanup into master 2018-02-02 09:52:45 -05:00
3 changed files with 5 additions and 25 deletions
Showing only changes of commit 5ec0ce09e1 - Show all commits

View File

@@ -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/))

View File

@@ -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
// + its 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"),

View File

@@ -25,10 +25,9 @@ module.exports = function(options) {
options.debug = options.debug || false
options.timeout = options.timeout || 0
// we cant 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 cant 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
}