[Bug 20913] [Custom]: What does inheriting from existing HTML element really mean?

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

--- Comment #32 from Daniel Buchner <danieljb2@gmail.com> ---
(In reply to comment #30)
> a) If Foo is an existing HTML element, use createElement only
> b) If Foo is a custom element that doesn't inherit from any existing HTML
> element, use either createElement or constructor
> c) If Foo is a custom element that does inherit from an existing HTML
> element, use constructor only.
> c.1) .. or use a new createElement API with "is" attribute argument.
> 
> Woe to Bob. Especially if colleague Jill decided that Foo should benefit
> from inheriting from an existing HTML element. But maybe I am worrying too
> much :)

Woe to Bob indeed. In regard to the document.createElement('x-foo') case, you
say this: "Intuitively, the author would expect that an instance that inherits
from HTMLButtonElement behaves like an HTMLButtonElement." <-- I completely
agree

There has to be a way to get to a place where native-inheriting custom elements
can be declared via the existing createElement style of element generation. If
we can figure out a way to do it, we should.

However, if we _must_ enforce a special case when generating native-inheriting
custom elements, I agree that extending createElement to take an attributes
object is not a bad idea (in fact, having createElement take an attributes
object is a pretty nifty addition itself). This way developers could do:
document.createElement('button', { is: 'x-foo' }). While, it's not the perfect
solution, it can be polyfilled and using is="" when extending native elements
is livable.

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

Received on Monday, 18 February 2013 16:20:10 UTC