Defining a constructor for Element and friends

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).


-- 
https://annevankesteren.nl/

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