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

Use convention for selecting elements #30

Open
skulptur opened this issue Jun 28, 2020 · 1 comment
Open

Use convention for selecting elements #30

skulptur opened this issue Jun 28, 2020 · 1 comment

Comments

@skulptur
Copy link
Contributor

Selecting by className is bad practice as that ties the styling with the selection, and changes affect more files/places than they should.

Proposal is to use something like data-ref="next-button" and that the built in selectors only get the string "next-button" rather than the whole selector.

Users can still use element.querySelector if they need to bypass the rule, but it will be more apparent.

@ThaNarie
Copy link
Member

The downside of this is tight coupling between the HTML and the JS - which we want to avoid as much as possible.

Example;
If i want to add some interactivity to an existing element, I normally only have to update the JS.
Now I also have to add a data-ref to the HTML, which cause the BE templates to be updated as well.

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

2 participants