Switch linting to ESLint and Prettier (#191)

* Switch linting to ESLint and Prettier
* Clean up config
* Prettier fixes
This commit was merged in pull request #191.
This commit is contained in:
BehindTheMath
2019-02-13 22:26:57 -05:00
committed by GitHub
parent 2c6506af65
commit 3c1a4b2e18
23 changed files with 4674 additions and 2222 deletions

View File

@@ -1,70 +1,71 @@
var clone = require("../util/clone.js")
var newUid = require("../uniqueid.js")
var trigger = require("../events/trigger.js")
var clone = require("../util/clone");
var newUid = require("../uniqueid");
var trigger = require("../events/trigger");
module.exports = function(responseText, request, href, options) {
options = clone(options || this.options)
options.request = request
options = clone(options || this.options);
options.request = request;
// Fail if unable to load HTML via AJAX
if (responseText === false) {
trigger(document, "pjax:complete pjax:error", options)
trigger(document, "pjax:complete pjax:error", options);
return
return;
}
// push scroll position to history
var currentState = window.history.state || {}
window.history.replaceState({
var currentState = window.history.state || {};
window.history.replaceState(
{
url: currentState.url || window.location.href,
title: currentState.title || document.title,
uid: currentState.uid || newUid(),
scrollPos: [document.documentElement.scrollLeft || document.body.scrollLeft,
document.documentElement.scrollTop || document.body.scrollTop]
scrollPos: [
document.documentElement.scrollLeft || document.body.scrollLeft,
document.documentElement.scrollTop || document.body.scrollTop
]
},
document.title, window.location)
document.title,
window.location.href
);
// Check for redirects
var oldHref = href
var oldHref = href;
if (request.responseURL) {
if (href !== request.responseURL) {
href = request.responseURL
href = request.responseURL;
}
}
else if (request.getResponseHeader("X-PJAX-URL")) {
href = request.getResponseHeader("X-PJAX-URL")
}
else if (request.getResponseHeader("X-XHR-Redirected-To")) {
href = request.getResponseHeader("X-XHR-Redirected-To")
} else if (request.getResponseHeader("X-PJAX-URL")) {
href = request.getResponseHeader("X-PJAX-URL");
} else if (request.getResponseHeader("X-XHR-Redirected-To")) {
href = request.getResponseHeader("X-XHR-Redirected-To");
}
// Add back the hash if it was removed
var a = document.createElement("a")
a.href = oldHref
var oldHash = a.hash
a.href = href
var a = document.createElement("a");
a.href = oldHref;
var oldHash = a.hash;
a.href = href;
if (oldHash && !a.hash) {
a.hash = oldHash
href = a.href
a.hash = oldHash;
href = a.href;
}
this.state.href = href
this.state.options = options
this.state.href = href;
this.state.options = options;
try {
this.loadContent(responseText, options)
}
catch (e) {
trigger(document, "pjax:error", options)
this.loadContent(responseText, options);
} catch (e) {
trigger(document, "pjax:error", options);
if (!this.options.debug) {
if (console && console.error) {
console.error("Pjax switch fail: ", e)
console.error("Pjax switch fail: ", e);
}
return this.latestChance(href)
}
else {
throw e
return this.latestChance(href);
} else {
throw e;
}
}
}
};