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

Improve link click routing #7

Open
dreitzner opened this issue May 22, 2023 · 0 comments
Open

Improve link click routing #7

dreitzner opened this issue May 22, 2023 · 0 comments

Comments

@dreitzner
Copy link

First of all for the link click routing mixin. This helped me a lot 😊

Here a little feedback, to make it a little more robust.

https://github.com/d-darwin/darwin-vue-ui/blob/main/src/mixins/linkClickRouting.js#L49
This could be rewritten with:

// selects all <a> where href starts with "/"
// https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors#syntax
this.linksTags = this.$el.querySelectorAll('a[href^="/"]');

(if you want to be extra fancy you could even exclude the target blank with this selector this.$el.querySelectorAll('a[href^="/"]:not([target="_blank"])')

By doing this you will set possibly less event listeners and can omit the href check here

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