-
Notifications
You must be signed in to change notification settings - Fork 20
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
Don't change anchor links to use the history API if the router doesn't have a match #18
base: master
Are you sure you want to change the base?
Don't change anchor links to use the history API if the router doesn't have a match #18
Conversation
Allow links to be handled by the browser if the router does not support the route. In the case where you may be proxy-passing from a server-side routing web app to a client-side routing web app, many of the URLs may be unsupported client-side. This allows the links to pass through to the parent router.
We weren't properly binding the anchor click handler so it wasn't being unbound properly
Hmm I didn't account for when there are multiple router-slots on screen. With this PR, it would put multiple click listeners on the window and only respond to the router that attached it. I think this can be solved by only attaching it to the top-level router. Testing this idea. |
Previously if there were multiple router-slots on-screen, each one would have its own AnchorHandler responding to itself. We only want one at the root.
That was an easy fix. Now I'm only binding the anchor handler in the root router so we only get one click handler and since it's being used to determine whether the route should be handled or not, the root router should be the last in line to make that determination if the route can be handled. |
@jbuckner - great, many thanks for this. Actually, I favored this router mostly because of the way it manages nested |
The use case for this is integrating
router-slot
into a server-side routed web app where we're proxy-passing from the same parent URL. ie:foo.com/about
andfoo.com/products
where/about
is usingrouter-slot
, but/products
is not. Anchor links to/products
will currently try to be handled byrouter-slot
because it's a relative link, even if you don't have a route for it.With this change, if you don't have a catch-all route in
router-slot
, it will allow the browser to redirect the link to the server-side routed/products
URL.If the app has a catch-all route, it will still be handled client-side.