W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2013

Re: Monkeypatching document.createElement() is wrong

From: Alex Russell <slightlyoff@google.com>
Date: Tue, 12 Feb 2013 03:46:02 -0800
Message-ID: <CANr5HFXWW4w-hKenWLNDxDkyfgsd=n1wZTSMd3o4-104dz=--Q@mail.gmail.com>
To: Anne van Kesteren <annevk@annevk.nl>
Cc: WebApps WG <public-webapps@w3.org>, Dimitri Glazkov <dglazkov@google.com>, Dominic Cooney <dominicc@google.com>, Erik Arvidsson <arv@google.com>, Tab Atkins <tabatkins@google.com>, Scott Miles <sjmiles@google.com>
+others who have been involved in the design phase of the Google proposal

So there are several viable points in the design space here. I'll try to
outline them quickly:


   1. An internal lifecycle driver for element + shadow creation.
   In this strategy, an element's constructor either calls
   createShadow()/finalizeInitialization() methods directly, or calls the
   superclass constructor to ensure that they are invoked.
   2. External lifecycle driver.
   In this design, it's up to whoever new's up an Element to ensure that
   it's fully formed before injecting it into the DOM.

The current design codifies the second.

Regarding Audio() and Image(), it's possible to model them as having
internal "already called" flags on their shadow creation methods that
prevent double initialization by createElement(). But I agree that it's
messier and muddies the de-sugaring story.

Dimitri? Dominic?

On Tuesday, February 12, 2013, Anne van Kesteren 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.
>
>
> --
> http://annevankesteren.nl/
>
>
Received on Tuesday, 12 February 2013 11:53:16 GMT

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