On Aug 31, 4:00 pm, "Ian Bambury" <[EMAIL PROTECTED]> wrote:
> Another (definitely 'Breaking') change in 1.5.2 from 1.5.1 is that
>
> public final native String getAttribute(String name) /*-{
> return this.getAttribute(name);
> }-*/;
> in Element has become
>
> public final native String getAttribute(String name) /*-{
> return this.getAttribute(name) || '';
>
> }-*/;
>
> i.e. if the attribute does not exist, then for some reason, you don't get
> the expected null, you get an empty string.
>
> Could someone from Google explain why there has been this diversion from the
> path of 'least surprise'?
Because that's how the DOM is defined:
http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-745549614
> What suddenly became so wrong with returning what
> JS gives you?
http://code.google.com/p/google-web-toolkit/source/detail?r=3568
Apparently, not all browsers give you nulls.
> Could you mention it in the release notes as a breaking
> change? It breaks any number of my apps, all of which check for null,
> because that's what you used to get.
I'd say that hasAttribute() is missing, but unfortunately, IE doesn't
seem to support it:
http://www.quirksmode.org/dom/w3c_core.html#t95
(at least before IE8:
http://msdn.microsoft.com/en-us/library/cc304121%28VS.85%29.aspx
)
IE has a somewhat bizarre getAttribute implementation:
http://msdn.microsoft.com/en-us/library/ms536429(VS.85).aspx
...one that happens to return null when hasAttribute would have
returned false.
On Aug 31, 4:09 pm, "Ian Bambury" <[EMAIL PROTECTED]> wrote:
> And now I can't tell the difference between an attribute which is missing,
> and an attribute which is there but empty...
Blame Microsoft eventually at first...
...but having an Element.hasAttribute deferring to
getAttribute()==null in case hasAttribute doesn't exist would probably
be enough to get this "fixed" (or better: deferred binding, which
would also use getAttribute(name, 2) for IE to get the appropriate
behavior)
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---