W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2011

Re: Components/constructable DOM elements: mandatory tag registration?

From: Dominic Cooney <dominicc@google.com>
Date: Fri, 26 Aug 2011 07:25:13 -0700
Message-ID: <CAHnmYQ89XVNDVy9CDHph0ZEo40+2ZkO5ySTYVFMexUa9Rcdz7Q@mail.gmail.com>
To: Roland Steiner <rolandsteiner@google.com>
Cc: WebApps WG <public-webapps@w3.org>, Dimitri Glazkov <dglazkov@google.com>, Hajime Morita <morrita@google.com>
I think HTMLElement.call should throw if there’s not an associated tag name.

However exactly how that association happens, I am not sure.
JavaScript can’t rely on the 'constructor' property. Shadowing the
tagName attribute on the prototype is not ideal, because it may be
mutable and it would be confusing if it was mutated.

Alternatively we could require subtypes of some specific tag, like
HTMLDivElement, and use that tag name if there's no registered tag
name. That means the UA can't limit special casing to x- elements,
although I think that is OK.

Dominic

On Fri, Aug 26, 2011 at 1:16 AM, Roland Steiner
<rolandsteiner@google.com> wrote:
> From the discussion about "x-" prefixed names another question crossed my
> mind: Suppose an author defines a component, but doesn't register a tag
> name. AFAICT, at this point nothing prevents him from inserting such a new
> element into the DOM. E.g.:
> <div id="div"></div>
> <script>
>     function MyNewElement() {
>         HTMLElement.call(this);
>         // ...
>     }
>     var div = document.getElementById("div");
>     div.appendChild(new MyNewElement());
>
>     // ... Look Ma, no Element.register() call!
>
>     var text = div.innerHTML;  // <- what does this return?
> </script>
>
> Cheers,
> - Roland
Received on Friday, 26 August 2011 14:25:39 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:47 GMT