W3C home > Mailing lists > Public > public-script-coord@w3.org > July to September 2011

Re: [WebIDL] troublesome names, property attributes and related issues

From: Garrett Smith <dhtmlkitchen@gmail.com>
Date: Fri, 26 Aug 2011 16:07:56 -0700
Message-ID: <CABZUbM040ud_HFg8gUFn6zWv3QYB0wOWAe_E9XHm72cJSf_SJA@mail.gmail.com>
To: Jonas Sicking <jonas@sicking.cc>
Cc: Allen Wirfs-Brock <allen@wirfs-brock.com>, public-script-coord@w3.org
On 8/26/11, Jonas Sicking <jonas@sicking.cc> wrote:
> On Thu, Aug 25, 2011 at 10:21 PM, Allen Wirfs-Brock
> <allen@wirfs-brock.com> wrote:

> Ah, ELEMENT_NODE doesn't live on the Document interface, it lives on
> the Node interface. So both the Node constructor and all instances of
> the Node interface (such as document) have the ELEMENT_NODE property.
> I'm not married to having instances contain constants though. If no
> other browsers do that, then it's likely not required for webcompat
> and could be dropped.
Interface constants are specified to be available. It is theoretically
useful to have code that checks the nodeType property:
/* GOOD EXAMPLE: code is very clear */
if(node.nodeType == node.ELEMENT_NODE)

That approach isn't used because IE versions failed to support
interface constants.

So code will sometimes check against a number, and then add a comment
to explain what that is:

/* BAD EXAMPLE: Comment and nondescript numeric code.
 Comments should explain *why* not *what* */
if(node.nodeType == 1) // document
Received on Friday, 26 August 2011 23:08:50 UTC

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