On Nov 17, 6:14 am, bhomass <[email protected]> wrote:
> I have this statement
>                 NodeList<Node> childNodes = tdElement.getChildNodes();
>                 for (int i=0; i<childNodes.getLength(); i++){
>                         Node childNode = childNodes.getItem(i);
>                         if (childNode instanceof Element&& !"#text".equals
> (childNode.getNodeName())){
>                                 dosomething();
>                         }
>                  }
>
> but the #text nodes get thru the if (childNode instanceof Element)
> check. I have to add
>
> if (childNode instanceof Element&& !"#text".equals
> (childNode.getNodeName())
>
> to fix it. I am sure #text is not an element, and this problem does
> not occur in IE, only in FF.
>
> anyone else knows about this anomaly?

That's not a bug: Element is a JavaScriptObject, and all
JavaScriptObject-derived class are 'instanceof' others.
See 
http://code.google.com/webtoolkit/doc/1.6/DevGuideCodingBasics.html#DevGuideOverlayTypes
and particularly 
http://sites.google.com/site/io/surprisingly-rockin-javascript-and-dom-programming-in-gwt
(this is explicitly spelled out at slide 26) and
http://code.google.com/p/google-web-toolkit/wiki/OverlayTypes (search
for "instanceof")

In your case, the fix is easy:

   if (Element.is(childNode)) {
      dosomething();
   }

--

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=.


Reply via email to