Use the same options object in handle-response as in send-request

Instead of cloning this.options again in handle-response.js, pass
the options object from send-request.js. This way,
pjax.state.options will also have the request options.
This commit is contained in:
Behind The Math committed 2018-04-12 18:26:02 -04:00
1 parent 358b6f6836
commit 59bd0fb595
5 files changed
+19 -14

No files matched your search

+6 -2
View File
@@ -37,7 +37,9 @@ tape("test events triggered when handleResponse(false) is called", function(t) {
tape("test when handleResponse() is called normally", function(t) {
var pjax = {
options: {},
options: {
test: 1
},
loadContent: noop,
state: {}
}
@@ -55,7 +57,9 @@ tape("test when handleResponse() is called normally", function(t) {
scrollPos: [0, 0]
}, "window.history.state is set correctly")
t.equals(pjax.state.href, "href", "this.state.href is set correctly")
t.same(pjax.state.options, pjax.options, "this.state.options is set correctly")
t.equals(Object.keys(pjax.state.options).length, 2, "this.state.options is set correctly")
t.same(pjax.state.options.request, request, "this.state.options is set correctly")
t.equals(pjax.state.options.test, 1, "this.state.options is set correctly")
t.end()
})