4 ms·
No worries, I like explaining it as a way for me to think through it myself. The problem is that if you add "js-" classes that probably means you add the equiv
by ianstormtaylor 13y ago
No worries, I like explaining it as a way for me to think through it myself.
The problem is that if you add "js-" classes that probably means you add the equivalent "js-"-less classes on the element as well. So then you just have duplication with the idea that they are "decoupled". Which might be good if it was true, but realistically if you change the component around to have a different DOM structure you're just going to end up changing both instances of the class anyways.
Really it's just trying to solve a problem that shouldn't be solved. Just agree upon an API (and put more effort into making the API good from the start) and then you don't have the problem to begin with. If you really do need to change the API later (which should happen rarely) then just put in the work to do it. Generally breaking API changes are rare if the component was design properly from the beginning, and if it stays small in scope.
Templates already have too many classes as it is without having to dupe them all :)