-
Notifications
You must be signed in to change notification settings - Fork 136
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
IDs and CSS classes have more than one purpose. #827
Labels
enhancement
New feature or request
Comments
In NNS-dapp we use |
cool I think we should do something similar. I keep running into issues because of that. |
nmattia
changed the title
ID's and CSS classes have more than one purpose.
IDs and CSS classes have more than one purpose.
Oct 11, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
While touching lots of parts of the
DOM
i broke quite a few things.Ex. the class
highlightBox
has some style on it but on the same time is used in the e2e tests. Changing the class caused test to fail. The situation is similar with some ID's (they are used to style but also to bind some behaviour to it). When changing anything that I thought would only be design related I would break things I did not expect to break.My proposal would be to separate CSS / JS and testing selector logic. A possible implementation could be:
.some-css-class
to style things.data-somefancyfunction
=>document.querySelector('[data-somefancyfunction]')
(Sometimes people like to use a class prefixed withjs-
rather than a data attribute, I like the data attribute because it can carry a value easily)data-e2etest="nameofthetest"
to select things within the tests. /* and maybe remove those for production */I think it would make it easier to do changes with no side-effects. It would be clear, what does what and by that made it easier to contribute to the code in the future.
What do you think?
Any thought on the separation of concerns itself and on my proposed implementation?
The text was updated successfully, but these errors were encountered: