Groups
Groups
Sign in
Groups
Groups
GWT Users
Conversations
About
Send feedback
Help
instanceof Element check fails in FF
4 views
Skip to first unread message
bhomass
unread,
Nov 17, 2009, 12:14:44 AM
11/17/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Google Web Toolkit
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?
Thomas Broyer
unread,
Nov 18, 2009, 11:03:30 AM
11/18/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Google Web Toolkit
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();
}
Reply all
Reply to author
Forward
0 new messages