pateketrueke / yrv

Your routing vibes! (for Svelte)
https://svelte.dev/repl/0f07c6134b16432591a9a3a0095a80de
161 stars 9 forks source link

How to ignore <a> fragments? #43

Closed tyteen4a03 closed 4 years ago

tyteen4a03 commented 4 years ago

How do I instruct yrv to ignore anchor fragments?

pateketrueke commented 4 years ago

I don't get you, can you provide an example? Thank you!

tyteen4a03 commented 4 years ago

<a id="top"> and clicking on <a href="#top"> does not work since yrv takes over trying to route it when it should be going to the #top.

pateketrueke commented 4 years ago

Oh gotcha! Do you think is fine to ignore all anchors except those starting with #/ instead? 🤔

tyteen4a03 commented 4 years ago

Maybe have it configurable so that when using the history API it ignores all fragments.

I don't plan on using hash and not allowing / is technically breaking the rules but eh.

tyteen4a03 commented 4 years ago

Any progress on this issue? :)

pateketrueke commented 4 years ago

Hi, the only way I found to detect these kind of events is through e.isTrusted — so, when true seems to be from regular anchor elements.

Otherwise I'm not able to found a way to differentiate because e does not include the element that originated the navigation change.

Update: seems like the same event is fired whenever the user clicks on back/fwd buttons, so is not suitable the isTrusted way — do you have in mind a way to differentiate between anchors and router links?

What do you think?

pateketrueke commented 3 years ago

I think a new issue would fit better, if I understood, we could add a particular attribute on those links we want to ignore, right?