[Bug 23808] New: [Custom]: Should be able to instantiate any custom element from just its name

https://www.w3.org/Bugs/Public/show_bug.cgi?id=23808

            Bug ID: 23808
           Summary: [Custom]: Should be able to instantiate any custom
                    element from just its name
           Product: WebAppsWG
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Component Model
          Assignee: dglazkov@chromium.org
          Reporter: jan@quickui.org
        QA Contact: public-webapps-bugzilla@w3.org
            Blocks: 14968

It is not currently possible to always instantiate a custom element given just
its name.

Elements which derive from an existing HTML element must be instantiated with
document.createElement(name,type), where type is the base HTML element. All
other elements can be created via document.createElement(name). Unfortunately,
this distinction means that, given just a name, it isn't possible to create an
instance of a custom element.

This presents a significant limitation on certain types of meta-elements that
can take the name of *another* element and create instances of those. For
example, see the thread at
https://github.com/Polymer/polymer/issues/334#issuecomment-27610381, which
discusses a custom element that renders a month calendar. For flexibility, this
calendar element wants to accept the name of another element class that should
be used to render the individual days in the calendar. That is, the calendar is
a meta-element that wants to instantiate other elements (here, for the days).
Such a meta-element cannot easily be constructed.

Another common type of meta-element would be visual design tool which, given a
list of element names, wants to be able to present a user interface that can
create instantiates of those elements on demand.

A meta-element could be designed to accept both a name ("my-button") and a base
type ("button"), but this becomes cumbersome. Given just the name "my-button",
it seems that it should be possible to do one or both of the following:
1) Invoke createElement("my-button") and get back a <button is="my-button">.
2) Have a facility that, given just an element name like "my-button", can look
up its constructor or prototype. This would at least allow one to inspect the
prototype chain and determine whether createElement(name) or
createElement(name,type) is required. Alternatively, the facility could accept
an element name and return the name of the element type it extends.

The lack of such a facility is likely to force people to create custom elements
that wrap a standard HTML element (i.e., include an instance in their template)
rather than extend them, which would be an unfortunate limitation as the
semantics are quite different.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Tuesday, 12 November 2013 19:40:53 UTC