Re: [w3c/webcomponents] [idea] Allow HTML Element attributes to accept any type of value, not just strings. (#519)

@sebmarkbage

> FWIW React uses properties when it can. E.g. we don't want to first stringify a true/false value and pass the string 'checked' when we can just directly call .checked = true.

Good point! That's definitely good to take advantage of when available. It also requires making some sort of runtime whitelist on what is available, which can be avoided for other cases (generic cases that don't have associated properties or accessors) if attributes can accept non-string values.

> If I had my way, custom elements wouldn't support attributes directly but always translate them to property operations so that custom element authors are encouraged to use them - always

I think simply allowing non-string attributes is exactly the same solution (but better, because it is already part of spec: DOM elements have attributes and they are set with setAttribute/getAttribute).

I also posted a new comment with examples while you were making your comment. What do you think of those (above)?

As for events, is EventTarget with addEventListener/removeEventListener not enough?

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/519#issuecomment-225452154

Received on Sunday, 12 June 2016 18:21:55 UTC