Stimulus: [feature] BEM class instead of data-target

Created on 15 Feb 2018  路  1Comment  路  Source: hotwired/stimulus

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() {

  }
}

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.

>All comments

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.

Was this page helpful?
0 / 5 - 0 ratings