Abort previous pending XHR when navigating #114
Reference in New Issue
Block a user
Delete Branch "fix/abort-pending-xhr"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR adapts the basic concept from https://github.com/defunkt/jquery-pjax/pull/395/files.
Tests included, plus an extra example page to make it easy to test in-browser, using Chrome Dev Tool's network throttling functionality or similar.
Fixes #9.
I believe this will fix #27 as well.
A bonus fix, nice! 🎉
Nice work
Thanks @MoOx! @BehindTheMath, are we good to merge?
@robinnorth I made 2 inline comments on
noop.jsandabort-request.js. Did you see them?@BehindTheMath they're not showing up, for some reason. Would you mind adding them again?
Is this callback ever called? Do you want to add a test that fails if it is?
Is there any reason not to inline this?
Can you see them now?
Yes, thank you.
I broke this out as a separate module so that it could be used whereever a noop function is required, which is currently in 2 places in the library... but didn't then update the second usage (in the 'stupidPjax' fallback) 😊
Good idea, will do that.
Actually, that callback is never called, because if
abortRequest(r)doesn't abort the request, the next assert (t.equal(r.readyState, 0, "xhr readyState is '0' (ABORTED)"))immediately fails, so I don't think we do need to add anything else in.Can you rename the file to
noop.js?Tape has a
t.fail()function. I think adding that will make it more apparent that the callback is not supposed to be called. What do you think?Yes, nice catch, this is why code reviews are important 😉
I did add that and then remove it again because the callback would never fire, but I take the point about making it explicit that the callback shouldn't fire, will add that back in.
@@ -5,6 +5,8 @@ var forEachEls = require("./lib/foreach-els.js")var newUid = require("./lib/uniqueid.js")var noop = require("./lib/util/noop")Can you change this as well to
noop.js?@@ -0,0 +1,8 @@var noop = require("./util/noop")Can you change this as well to
noop.js?@@ -0,0 +1,8 @@var noop = require("./util/noop")I can, although half the library uses this Node convention of not appending the module file extension to the require call -- we should probably standardise this one way or the other -- something for #97?
@@ -0,0 +1,8 @@var noop = require("./util/noop")You're right; I didn't notice that.
I guess leave it for now, and make a comment in #97.