W3C home > Mailing lists > Public > www-dom@w3.org > July to September 2009

Re: HTML tag names vs. IDL interface names.

From: Cameron McCormack <cam@mcc.id.au>
Date: Wed, 15 Jul 2009 11:00:06 +1000
To: www-dom@w3.org
Message-ID: <20090715010006.GA32077@arc.mcc.id.au>
Hi Dimitry.

Dimitry Golubovsky:
> I am trying to find a summary on the correspondence between HTML tag
> names, and (Web) IDL interface names related to DOM nodes representing
> HTML tags..

This sounds more like a question for the HTML WG, public-html@w3.org.

> In general, the relationship is straightforward, like <body>
> corresponds to HTMLBodyElement. There are however exceptions like
> <img> corresponds to HTMLImageElement.
> 
> Have these exceptions been summarized anywhere (preferrably in some
> parseable form)? I have tried to find relevant program sources, but I
> can only see hardcoding of such exceptions rather than reference to
> some generalized source.

It’s not an *easily* parseable form, but you can get the HTML 5 spec
source and extract these things.  Here’s a bookmarklet that does this.
Open the spec http://dev.w3.org/html5/spec/ in Firefox and then use the
following bookmarklet on it:

----
javascript:var i, j, a = [], l, name, s = '';
for (i = 1; i <= 6; i++) {
  l = document.getElementsByTagName('h' + i);
  for (j = 0; j < l.length; j++) {
    n = l[j];
    if (n.textContent.match(/The ([^ ]*) element/)) {
      name = RegExp.$1;
      if (n.nextSibling.textContent.match(/interface (HTML[^ ]*)/)) {
        s += name + ': ' + RegExp.$1 + '<br>';
      }
    }
  }
}
document.write('<pre>' + s);
document.close();
----

Maybe it even works in other browsers.  I haven’t tesed it to see if it
missed any elements.

-- 
Cameron McCormack ≝ http://mcc.id.au/
Received on Wednesday, 15 July 2009 01:00:55 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:14:02 GMT