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

Re: Defining a constructor for Element and friends

From: Simon Pieters <simonp@opera.com>
Date: Mon, 19 Jan 2015 11:01:35 +0100
To: "Anne van Kesteren" <annevk@annevk.nl>, "Domenic Denicola" <d@domenic.me>
Cc: "WebApps WG" <public-webapps@w3.org>, "www-dom@w3.org" <www-dom@w3.org>, "Yehuda Katz" <wycats@gmail.com>
Message-ID: <op.xspfgx1didj3kv@simons-mbp>
On Fri, 16 Jan 2015 20:08:30 +0100, Domenic Denicola <d@domenic.me> wrote:

> From: Anne van Kesteren [mailto:annevk@annevk.nl]
>> How can that work if the custom element constructor needs to look in  
>> the registry to find its name? Pick a name at random?
> Nah, it just automatically starts acting like HTMLQuoteElement: the  
> localName option becomes required. See
> https://github.com/domenic/element-constructors/blob/5e6e00bb2bb525f04c8c796e467f103c8aa0bcf7/element-constructors.js#L229-L233
> https://github.com/domenic/element-constructors/blob/5e6e00bb2bb525f04c8c796e467f103c8aa0bcf7/element-constructors.js#L51-L54

Consider if HTML adds a new element that uses the same interface as  
another element, let's say <foobar>, so that both <foobar> and <data> use  
HTMLDataElement. When this happens, new HTMLDataElement() starts throwing?

Similarly, if HTML is changed such that an element changes to use a more  
specific interface, e.g. <ruby> changes from HTMLElement to  
HTMLRubyElement, then new HTMLElement('ruby') will start throwing?

If so, it seems it removes some flexibility with how HTML uses interfaces.  
In particular many elements use HTMLElement and it should be possible to  
change them to use a more specific interface. How do you envision to solve  
this? Should we assign element-specific interfaces to all post-HTML4  
elements now, just in case? Or make new HTMLElement('ruby') create an  
HTMLRubyElement? Something else?

Simon Pieters
Opera Software
Received on Monday, 19 January 2015 10:00:05 UTC

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