Hacker News new | comments | show | ask | jobs | submit login

Custom attributes are a deal-breaker for me personally.



Since 1.0.0rc1 that was released 5 months ago (1.0.0 went gold 2 months ago), the custom attributes used for by AngularJS can be turned into valid html5 attributes by prepending the "ng-*" AngularJS attributes with "data-". For example,

  <html ng-app>
can be turned into a valid attribute by making it

  <html data-ng-app>
I'm really glad to see how quickly the AngularJS team is addressing concerns like these. AngularJS is moving very fast, and there is a lot of room for improvements in documentation. But a quick check with the changelog would have showed that AngularJS supports the use of valid custom attributes for directives almost half a year ago.


Angular supports using data-attributes or using classes, I just prefer using custom attributes:

http://docs.angularjs.org/guide/directive


You actually have a fair bit of flexibility here, if that helps: https://github.com/angular/angular.js/blob/master/CHANGELOG....


is there a concrete reason for not liking them, other than the content possibly being "non-valid"?

I also feel somewhat dirty when using custom attributes, and I admit I preferred xmli-sh HTML and namespaces a-la ng:attr.. but is there any practical difference?


I think a lot of folks are afraid it's a slippery slope to this[1]: http://wekeroad.com/images/koouch.png

[1] http://wekeroad.com/2011/08/18/my-eyes-please-youre-killing-...


they're not semantic. just like css classes are not semantic... also, ids are not semantic either.


... and neither is JavaScript.

We're dealing with applications here, not documents, and even in the latter case, your views regarding ids and classes are extreme.

Angular templates, more than just markup, are the skeleton of your application. The markup they generate is as semantic as you make it.


the sarcasm tag is also not semantic


:-)

Actually, I hesitated before posting... I had ruled sarcasm out because purely snarky posts are usually frowned upon here, and your parent post was asking a legitimate question...

That being said, we obviously agree on the topic.


poe's law?

In all seriousness though. That is kind of the correct answer to the parent. There's kind of this weird attachment to a whole bunch of weird 'best practices' in the design front. Many of them conflicting, many of them not well thought out. (There are some good ones coming out).

It's similar to twitter's bootstrap. Designers think it's horrible, if you believe the kind of blog with grey text on a grey background. But I can't believe people would recommend against it when they've seen the alternative.


True.

That's some cool stuff you make with your band, btw. What do you play?


It is possible to prefix them with data- thus making it kinda valid html.


I held out for a while, but data- attributes really do make writing reusable JavaScript components SO much easier - if you use them responsibly I don't see any downside to them at all.


I agree, I was talking about non data- custom attributes, but others have pointed out that you can use the data- versions as well, which is acceptable.


In an era where any reasonably complex web application requires JavaScript, I'm less worried about the purity of the HTML. And with HTML5 "data-" attributes, I'm even less so.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: