Skip to content

Commit ee0887c

Browse files
committed
Ensure pjax.state is consistent before pjax:beforeReplace event
1 parent fc4b710 commit ee0887c

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

jquery.pjax.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,10 +447,10 @@ function onPjaxPopstate(event) {
447447
if (contents) {
448448
container.trigger('pjax:start', [null, options])
449449

450+
pjax.state = state
450451
if (state.title) document.title = state.title
451452
container.trigger('pjax:beforeReplace', [contents, options])
452453
container.html(contents)
453-
pjax.state = state
454454

455455
container.trigger('pjax:end', [null, options])
456456
} else {

test/unit/pjax.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ if ($.support.pjax) {
547547
ok(contents)
548548
equal($(event.target).text(), beforeContent)
549549
equal(options.url, "hello.html")
550+
ok(frame.$.pjax.state.url.match("/hello.html"))
550551
})
551552
frame.$("#main").on("pjax:success", function(event) {
552553
notEqual($(event.target).text(), beforeContent)
@@ -866,6 +867,7 @@ if ($.support.pjax) {
866867
equal(frame.location.pathname, "/home.html")
867868
// Remember: the content hasn't yet been replaced.
868869
notEqual($(event.target).html(), originalContent)
870+
ok(frame.$.pjax.state.url.match("/home.html"))
869871
start()
870872
})
871873

0 commit comments

Comments
 (0)