Remove old switchFallback code
This commit is contained in:
committed by
Robin North
parent
70f6383702
commit
5ec0ce09e1
@@ -394,8 +394,7 @@ in order to skip browser cache.
|
|||||||
|
|
||||||
##### `debug` (Boolean, default: `false`)
|
##### `debug` (Boolean, default: `false`)
|
||||||
|
|
||||||
Enables verbose mode & doesn't use fallback when there is an error.
|
Enables verbose mode. Useful to debug page layout differences.
|
||||||
Useful to debug page layout differences.
|
|
||||||
|
|
||||||
##### `currentUrlFullReload` (Boolean, default: `false`)
|
##### `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:send` - Fired after the Pjax request begins.
|
||||||
* `pjax:complete` - Fired after the Pjax request finishes.
|
* `pjax:complete` - Fired after the Pjax request finishes.
|
||||||
* `pjax:success` - Fired after the Pjax request succeeds.
|
* `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/))
|
`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/))
|
||||||
|
|
||||||
|
|||||||
18
index.js
18
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)
|
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) {
|
latestChance: function(href) {
|
||||||
window.location = href
|
window.location = href
|
||||||
},
|
},
|
||||||
@@ -139,16 +130,7 @@ Pjax.prototype = {
|
|||||||
} catch (e) { }
|
} catch (e) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
// try {
|
|
||||||
this.switchSelectors(this.options.selectors, tmpEl, document, options)
|
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"),
|
abortRequest: require("./lib/abort-request.js"),
|
||||||
|
|||||||
@@ -25,10 +25,9 @@ module.exports = function(options) {
|
|||||||
options.debug = options.debug || false
|
options.debug = options.debug || false
|
||||||
options.timeout = options.timeout || 0
|
options.timeout = options.timeout || 0
|
||||||
|
|
||||||
// we can’t replace body.outerHTML or head.outerHTML
|
// We can’t replace body.outerHTML or head.outerHTML.
|
||||||
// it create a bug where new body or new head are created in the dom
|
// 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 get 2 body
|
// If you set head.outerHTML, a new body tag is appended, so the DOM has 2 body nodes, and vice versa
|
||||||
// & it break the switchFallback which replace head & body
|
|
||||||
if (!options.switches.head) {
|
if (!options.switches.head) {
|
||||||
options.switches.head = defaultSwitches.switchElementsAlt
|
options.switches.head = defaultSwitches.switchElementsAlt
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user