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

TonicRouter seems to have issues working with hash fragments #125

Open
keks opened this issue Feb 7, 2023 · 0 comments
Open

TonicRouter seems to have issues working with hash fragments #125

keks opened this issue Feb 7, 2023 · 0 comments

Comments

@keks
Copy link

keks commented Feb 7, 2023

I want to host my Tonic app using static file hosting, so I can't have users request paths that don't really exist (actually I am experimenting with web extensions, so it's not really hosted at all). That's why I keep my application paths inside the hash fragment of the URL. I can't get TonicRouter to match these, though.

Initially I only got a blank page (so not even the none router matched), but I managed to resolve that using the pushState-hack. but still, I am not able to get it to match the itworks-router.

Is this intended?

import Tonic from '@socketsupply/tonic';
import {TonicRouter} from '@socketsupply/components/router';

class MWE extends Tonic {
   connected () {
    window.history.pushState({},"", window.location); // HACK
    this.addEventListener('match', this.reRender);
  }
  
  render () {
    return this.html`
      <tonic-router id="itworks-router" path="/#/itworks">
        it works
      </tonic-router>
      
      <tonic-router id="notfound-router" none>
        it at least sort of works
      </tonic-router>
    `;
  }
}

Tonic.add(TonicRouter);
Tonic.add(MWE);

document.body.innerHTML = '<m-w-e id="container"></m-w-e>';
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

1 participant