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

Re: Defining a constructor for Element and friends

From: Ryosuke Niwa <rniwa@apple.com>
Date: Tue, 13 Jan 2015 10:50:32 -0800
Cc: Boris Zbarsky <bzbarsky@mit.edu>, Anne van Kesteren <annevk@annevk.nl>, WebApps WG <public-webapps@w3.org>, "www-dom@w3.org" <www-dom@w3.org>
Message-id: <4B74EB96-72F4-436C-892F-8075A6EE2C0D@apple.com>
To: Domenic Denicola <d@domenic.me>

On Jan 13, 2015, at 10:45 AM, Domenic Denicola <d@domenic.me> wrote:

> From: Ryosuke Niwa [mailto:rniwa@apple.com] 
> 
>> Shouldn't we throw in this case because the concert type of "somename" is HTMLUnknownElement?
> 
> Yes, that's exactly the current design. Hidden a bit:
> 
> https://github.com/domenic/element-constructors/blob/master/element-constructors.js#L4
> 
> This still leaves the potential hazard of someone doing `new HTMLUnknownElement("somename")` and their code breaking later once "someone" becomes a real tag... hopefully the "Unknown" is a bit more of a deterrent though?

Or, we could always throw an exception in the constructor of HTMLUnknownElement so that nobody could do it.  It would mean that libraries and frameworks that do support custom elements without "-" would have to use document.createElement but that might be a good thing since they wouldn't be doing that in the first place.

- R. Niwa
Received on Tuesday, 13 January 2015 18:51:24 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:27:25 UTC