I feel data-target very redundant in case of BEM usage.
Could we have targets declaration points to BEM class?
<div class="media-uploader" data-controller="media-uploader">
<div class="media-uploader__drop-area" ></div>
</div>
export default class extends Controller {
static targets = ['drop-area'];
connect() {
}
}
Imagine coming back to that HTML a year later. Would you know just by looking that the inner <div> has associated JavaScript behavior and that its class name shouldn't be changed or removed? Stimulus is all about making that association explicit, and encourages you to maintain a healthy Separation of Concerns.
Most helpful comment
Imagine coming back to that HTML a year later. Would you know just by looking that the inner
<div>has associated JavaScript behavior and that its class name shouldn't be changed or removed? Stimulus is all about making that association explicit, and encourages you to maintain a healthy Separation of Concerns.