We've been avoiding to restrict Angularjs directives to classes. Mostly because we found some sources which advised against it (including John Papas opinionated styleguide). At the same time we've been avoiding restricting it to elements since it would be in conflict with the W3C standards. (We're purists like that).
So, all we've been using is the restrict to attribute (no, we're not going to talk about the comment method). Which works fine in most cases but seems too loose when deploying a concrete object. E.G. A sidebar. This as well as that the replace: true
option will be deprecated, made me wonder why not use the restrict to class anyway. It seems to make sense:
<nav class="maarten-sidebar">
<!-- sidebar directive content -->
</nav>
In comparison to:
<div data-maarten-sidebar>
<!-- sidebar directive content -->
<nav class="sidebar"></nav>
</div>
It plays nicely with our CSS files as well. With some research we found some people advise against it. But the main reasons why not are not very clear. So my question actually is: What are the pitfalls of using restrict: 'C'