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

On 8/26/11, Jonas Sicking <> wrote:
> On Thu, Aug 25, 2011 at 10:21 PM, Allen Wirfs-Brock
> <> 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