Re: Monkeypatching document.createElement() is wrong

On Tue, Feb 12, 2013 at 3:24 AM, Anne van Kesteren <annevk@annevk.nl> wrote:

> If the goal of custom elements is to expose the guts of what happens
>
> https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/custom/index.html#monkeypatch-create-element
> is the wrong solution. Currently new Image() and createElement("img")
> are equivalent and no additional magic is required. Same for new
> Audio() and createElement("audio"). What we want is that
>
> var x = document.createElement(name)
>
> maps to / is identical to
>
> var x = new name's-corresponding-object
>
> and nothing else.
>

... and that's exactly how custom elements are being spec'd. See how
constructor is generated:
https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/custom/index.html#dfn-custom-element-constructor-generation

By the wrongness, do you mean the running shadow tree instantiation and
element finalization steps? If so, they are workarounds for our inability
to define an author-defined constructor.

There's a nice thread that tries to enable this and eliminate these extra
steps, but from what I understand, there's a monkey wrench thrown by
inability of current JS engines to accommodate the proposed design:
http://lists.w3.org/Archives/Public/public-webapps/2013JanMar/thread.html#msg250

:DG<

Received on Tuesday, 12 February 2013 17:06:32 UTC