domenic/html-as-custom-elements

Global attributes

Opened this issue · 4 comments

How do the implementation of global attributes fit into the bedrock idea?

http://www.w3.org/TR/html-markup/global-attributes.html

Does every element need to implement them separately? Does this behavior come along with extending the HTMLElement prototype?

The two that stand out as interesting to me are accesskey and title. Access keys could be implemented with keydown events and title dialogs with a css hover menu.

If you wanted to polyfill/prollyfill a new global attribute, where would that behavior go? Theres no equivalent of the createdCallback for every element with a certain attribute.

arv commented

I was also thinking about this. For example, to allow onfoo attributes for event listeners we would need a global mutation obsever. I guess mutation observers could fill the role but I think the might be too late.

someAncestor.setAttribute('onfoo', 'console.log(this, event)');
someDescendant.dispatchEvent(new Event('foo', {bubbles: true});
// The mutation observer has not yet delivered its records.
josh commented

Related is this discussion on attribute namespacing for custom elements.

http://lists.w3.org/Archives/Public/public-webapps/2014AprJun/0324.html

We use open issues to track missing web platform features; no need to close it just because we don't have a good solution :)

What you want is to replace the spec-defined slot for an attribute with your own. The first question would be where would these slots be placed and how much of a performance hit would that be.

And the second question would be what semantics are tied in this way and what semantics are tied through styling and other mechanisms.