Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no doubled history states #656

Merged
merged 2 commits into from Jan 23, 2014
Merged

no doubled history states #656

merged 2 commits into from Jan 23, 2014

Conversation

stevenvachon
Copy link
Contributor

@daffl
Copy link
Contributor

daffl commented Jan 8, 2014

Test?

@daffl daffl closed this Jan 8, 2014
@daffl daffl reopened this Jan 8, 2014
@stevenvachon
Copy link
Contributor Author

I'm not sure how to test this with anything other than what is seen. I had the same difficulty in #587. I tested back/forward and replacing history states; all works fine only now without doubling.

@justinbmeyer
Copy link
Contributor

Is it possible to register a few changes in the history, then call .back() and see if the url stays the same?

@stevenvachon
Copy link
Contributor Author

As I'd stated in #587, good idea; I'll create a test soon. I'm hoping that I can first fix the bug, though. The cause is can.route.attr's "change" event calling pushState too many times.

Solution(s):
Add a newURL != currentURL check in history.pushState
I'm, of course, open to better ideas.

Here is the flow:

// start
can.route.ready > can.route.setState

a.click >> anchorClickFix > history.pushState

// back and forward only
window.popstate >> can.route.setState


// overridden  function
history.pushState > can.route.setState

can.route.setState > can.route.attr

// onRouteDataChange is only called once, as it should be
can.route.attr > can.route.data > onRouteDataChange >> can.route.bindings.pushstate.setURL > history.pushState

@stevenvachon
Copy link
Contributor Author

patch-3 was merged into this (patch-4)… patch-3 may conflict with #699
just a heads up to save any time

@ghost ghost assigned justinbmeyer, andykant and zkat Jan 23, 2014
zkat pushed a commit that referenced this pull request Jan 23, 2014
@zkat zkat merged commit 6425d5d into canjs:master Jan 23, 2014
@stevenvachon stevenvachon deleted the patch-4 branch January 23, 2014 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants