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

Defining a constructor for Element and friends

From: Anne van Kesteren <annevk@annevk.nl>
Date: Wed, 7 Jan 2015 12:17:31 +0100
Message-ID: <CADnb78hptfVEeyna=FfN__Tv-UmRcY7PV48J+ecj2kaveThmZA@mail.gmail.com>
To: WebApps WG <public-webapps@w3.org>, "www-dom@w3.org" <www-dom@w3.org>
The important local slots for an element are its local name, prefix,
and namespace. I believe that for certain operations in HTML it is
also important to be able to instantiate an element along with several
attributes given by the parser so that when the first initialize
operations runs it has access to all of those. Though it seems HTML
could abstract over that somehow.

The main tricky thing here I think is whether it is acceptable to have
an element whose name is "a", namespace is the HTML namespace, and
interface is Element. I.e. can we break the invariant that the
combination of "a" and HTML namespace is always HTMLAnchorElement.

If we can break that invariant it seems rather easy to build the
hierarchy. The HTMLElement constructor would only take a local name
and always have a null prefix and HTML namespace. And
HTMLAnchorElement would always be "a". HTMLQuoteElement could accept
an enum and we could even add dedicated constructors for <q> and
<blockquote> (provided the web allows).

Received on Wednesday, 7 January 2015 11:18:01 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 18:14:43 UTC