Skip to content

Adding getByRole method.

Latest

Choose a tag to compare

@HenrikJoreteg HenrikJoreteg released this 21 Jan 01:07
· 21 commits to master since this release

Shortcut for fetching elements by their "role" attribute. This is for convenience and also to encourage the use of the role attribute for grabbing elements from the view.

So inside a view you can now do:

this.list = this.getByRole('people-list');

Using this convention makes it much less likely that designers and JS devs accidentally break each other's code.

Take for example:

<nav class="people" role="people-list"></nav>

It's very clear what that element will be populated with but also, the designer is free to add/change whatever classes they want, or even switch it to <ul> without breaking things.