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

Don't change anchor links to use the history API if the router doesn't have a match #18

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Prev Previous commit
Only bind the AnchorHandler in the root router-slot
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.
  • Loading branch information
jbuckner committed Jan 17, 2021
commit b8acb91cca1c9847b000f396a45c9ebc74f2a606
4 changes: 4 additions & 0 deletions src/lib/router-slot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ export class RouterSlot<D = any, P = any> extends HTMLElement implements IRouter
* Attach the anchor listener
*/
protected setupAnchorListener(): void {
// only bind the AnchorHandler to the root router
// otherwise, we get multiple click handlers,
// each responding to a different router
if (!this.isRoot) return;
this.anchorHandler = new AnchorHandler(this);
this.anchorHandler?.setup();
}
Expand Down