Re: Custom Elements: 'data-' attributes

> On May 13, 2014, at 2:37 AM, Anne van Kesteren <annevk@annevk.nl> wrote:
> 
>> On Mon, May 12, 2014 at 9:39 PM, Ryosuke Niwa <rniwa@apple.com> wrote:
>> But expandos are usually added to HTMLElement and other builtin elements, right?
> 
> Depends, might be on instances too.

Sure, authors can do anything they please to do but a typical workflow is to define a property on element's prototype.

>> What we're talking about here is adding properties and methods on a custom element, which is a subclass of HTMLElement so I don't think it'll cause the same issue.
> 
> If a site has if (ele.prop) you'd have that issue since that suddenly
> starts returning true for e.g. the <body> element or some such.
> Similar reason is why getElementById() is not available on elements.

Right. I think we need to discourage authors from using such an idiom on inprefixed author defined properties.

If authors are writing terrible code, there is so much we can do to mitigate that.

> Sole had the idea of providing hooks for attributes so a component can
> say it handles them rather than the user agent. That makes a lot of
> sense to me. That way you can grab any name, even existing ones.

Sounds like a sensible idea.

- R. Niwa

Received on Tuesday, 13 May 2014 16:55:07 UTC