2008/9/5 Thomas Broyer [EMAIL PROTECTED]

>
> --
> Interface Attr
> [...]
> The attribute's effective value is determined as follows: if this
> attribute has been explicitly assigned any value, that value is the
> attribute's effective value; otherwise, if there is a declaration for
> this attribute, and that declaration includes a default value, then
> that default value is the attribute's effective value; otherwise, the
> attribute does not exist on this element in the structure model until
> it has been explicitly added.
> ---
> i.e. an attribute's value cannot be 'null'.
>
> document.createAttribute("foo") for instance creates an attribute with
> an empty-string value, not null.
>

I don't think anyone is suggesting that an attribute holds a null.

The question is: what do you return when trying to get the value of an
attribute that doesn't exist?

<div question="Life, The Universe, and Everything"></div>

String answer = elem.getAttribute("answer");
It doesn't hold a value.
It doesn't hold an empty string.
It's not null either because it doesn't exist.

But in this case, all the browsers I looked at (IE/FF/Safari/Opera/Chrome),
in JavaScript, return a null and now, suddenly, between 1.5.1 and 1.5.2, GWT
decided to go its own way and return an empty string. And break my
programming. (To be fair, I don't think Google made a decision to break my
programs, but on the other hand, there was no consultation with the
user-base of this open-source framework, it just got put in and sent out on
the quiet.)

The difference between the browsers is when it comes to explicit attributes
- MS has the rule:

             "Returns a string, a number, or a Boolean, defined by
sAttrName. If an explicit attribute doesn't exist, an empty string is
returned. If a custom attribute doesn't exist, null is returned."

which makes more sense to me as it involves less coding in situations like
className where you are never going to worry about whether it's been set ot
not, just what it is, but will return null if a custome attribute has not
been set or if you make a typo.

If you *don't* return a null for custom attributes, then people will have no
indication that getAttribute("float") is probably not what they were after.

Ian

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to