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

Use the history API #31

Closed
ArtskydJ opened this issue Feb 8, 2016 · 9 comments
Closed

Use the history API #31

ArtskydJ opened this issue Feb 8, 2016 · 9 comments

Comments

@ArtskydJ
Copy link
Collaborator

ArtskydJ commented Feb 8, 2016

What do you think about using the history API after static rendering (#30) is completed?

The history API is 80% supported, and anyone without it could fall back to http requests.

See ponyfoo/stop-breaking-the-web.

The obvious downside being, that hashbang urls that are in use right now would have to be supported, or redirected to the correct page.

@TehShrike
Copy link
Owner

I would have used the history API from the beginning, except that it doesn't fire an onhashchange equivalent when you click on a link.

popstate doesn't fire when you click on a link, so we would also have to implement some kind of hack to make all links not actually visit the link that they pointed to, and fiddle with the history manually in those cases.

Related: TehShrike/abstract-state-router#48

@sundarj
Copy link

sundarj commented Apr 23, 2016

popstate doesn't fire when you click on a link because that's not how the History API works. If you want the link to modify the history programmatically you have to preventDefault() and then fire an equivalent pushState.

Either that or, on page load, use replaceState with that page's location.pathname

@TehShrike
Copy link
Owner

What event is fired when you click on a link where you can call event.preventDefault() and cancel the regular navigation to that other page?

@sundarj
Copy link

sundarj commented Apr 24, 2016

Well, click is: https://jsfiddle.net/df78oofa/

@TehShrike
Copy link
Owner

Yeah, watching for all click events and doing magical things when the clicked thing happens to be a link is the only way I know of too.

@sundarj
Copy link

sundarj commented Apr 24, 2016

I wouldn't call it 'magic', it's simply a different kind of navigation

@TehShrike
Copy link
Owner

Well, handling all click events and adding non-standard behavior to core browser behavior (what happens when you click on a elements) is a bit more magical than I usually roll. Not that it's inappropriate.

@TehShrike
Copy link
Owner

I'm going to close this for now, but the idea will be implemented eventually when we start working on the static-server support for Noddity.

@sundarj
Copy link

sundarj commented Jun 24, 2016

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

No branches or pull requests

3 participants