

Re: [dom3core] getAttribute

From: Elliotte Harold <elharo@metalab.unc.edu>
Date: Thu, 01 Dec 2005 07:59:47 -0500
Message-ID: <438EF3C3.6030106@metalab.unc.edu>
To: Maciej Stachowiak <mjs@apple.com>
CC: DOM mailing list <www-dom@w3.org>, andersca@mac.com

Maciej Stachowiak wrote:

> Both "" and null are reasonable things to return for a nonexistent 
> attribute, there is no deep principle at stake here. 

I disagree. I think there's an obvious difference between null and "". 
It allows one to distinguish between <img alt="" /> and <img />. This 
has semantic value. The former indicates that an explicit choice was 
made not to provide an alt attribute, and that therefore the image is 
purely presentational. The latter indicates that the author didn't 
consider the alt text to provide. The former is the empty string. The 
latter is null.

There are many other cases one could construct where the difference 
between having an attribute with an empty string value and not having an 
attribute at all is significant. Of course, it would be possible to use 
hasAttribute to make this distinction if necessary.

is it necessary? The issue of languages without any nulls is compelling, 
provided examples of such languages can be provided. Off the top of my 
head the only one I can think of is XSLT, but there's no DOM 
implementation for XSLT. Which languages someone might actually want to 
use inside a browser do not have a null value?

﻿Elliotte Rusty Harold  elharo@metalab.unc.edu
XML in a Nutshell 3rd Edition Just Published!
Received on Thursday, 1 December 2005 13:00:05 GMT
