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

Improper use of DOM events #116

Open
Voltra opened this issue Jan 5, 2023 · 0 comments
Open

Improper use of DOM events #116

Voltra opened this issue Jan 5, 2023 · 0 comments

Comments

@Voltra
Copy link

Voltra commented Jan 5, 2023

Current state: When clicking on a link that could trigger navigation, if the click event is prevented in an event listener, the navigation command is still processed.

Desired behavior: preventDefault being called on the event should cancel the navigation command before it's even issued

How it can be fixed: Check for e.defaultPrevented where it makes sense

Current hack fix:

class Router extends Highway.Core {
  navigate(e) {
    if(e?.defaultPrevented) {
      return;
    }

    super.navigate(e);
  }
}

const router = new Router(/* [...] */);
@Voltra Voltra changed the title Improper user of DOM events Improper use of DOM events Jan 5, 2023
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