Document.get().isOrHasChild(element) != isAttached() in CHrome ??

153 views
Skip to first unread message

Ed

unread,
Jul 17, 2012, 8:06:41 AM7/17/12
to google-we...@googlegroups.com
I show a widget in a popup: it's added to the RootPanel and then in a deferred command I noticed that in Chrome the Widget is attached (Widget.isAttached() method equals true) but when calling Document.get().isOrHasChild(widget.getElement()) it returns false.... I think this should be true also, just like I see in Firefox.

Any idea's why this is false in Chrome?

- Ed

Thomas Broyer

unread,
Jul 17, 2012, 10:57:08 AM7/17/12
to google-we...@googlegroups.com


On Tuesday, July 17, 2012 2:06:41 PM UTC+2, Ed wrote:
I show a widget in a popup: it's added to the RootPanel and then in a deferred command I noticed that in Chrome the Widget is attached (Widget.isAttached() method equals true) but when calling Document.get().isOrHasChild(widget.getElement()) it returns false.... I think this should be true also, just like I see in Firefox.

Any idea's why this is false in Chrome?


This is strange, isOrHasChild uses contains(), and document.contains(someElt) returns true for me in Chrome Dev Tools.
Note that Firefox uses a different code, based on http://www.quirksmode.org/blog/archives/2006/01/contains_for_mo.html (Node.contains has only been added in Firefox 9, according to the MDN https://developer.mozilla.org/en/DOM/Node.contains ), so it's not really a surprise that it returns a different value.

Have you tried Document.get().getBody().isOrHasChild(widget.getElement()) ?

Ed Bras

unread,
Jul 17, 2012, 11:46:54 AM7/17/12
to google-we...@googlegroups.com
Thanks Thomas for ur feedback.
I am still using FF 6.0 (because of the plugin hassle)  ;)... I am just about to push a test release and then have planned to update FF and it's plugin....
I will test it again then... (also with  Document.get().getBody().isOrHasChild(widget.getElement()) )
To be continued...

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/wkPFiXpViVUJ.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

Ed Bras

unread,
Jul 19, 2012, 5:51:17 AM7/19/12
to google-we...@googlegroups.com
I ust run some tests and noticed the following in Chrome (in FF 12 they all return true):
1) Document.get().isOrHasChild(element) -> false
2) Document.get().getDocumentElement().isOrHasChild(element) -> true
3) Document.get().getBody().isOrHasChild(element) -> true
4) widget.isAttache() -> true

Appearantly there is a difference between being attached to the Document node and Body node.
Why?
What to do next to isolate/solve this?
Note: the above statements are called in a DeferedCommand just after the widget is added to the RootPanel. It concers an widget that is shown as a popup panel (absolute positioned)

- Ed

Jeff Chimene

unread,
Jul 19, 2012, 1:08:13 PM7/19/12
to google-we...@googlegroups.com
On 07/19/2012 02:51 AM, Ed Bras wrote:
> I ust run some tests and noticed the following in Chrome (in FF 12 they
> all return true):

Well, that's annoying...

> 1) Document.get().isOrHasChild(element) -> false
> 2) Document.get().getDocumentElement().isOrHasChild(element) -> true
> 3) Document.get().getBody().isOrHasChild(element) -> true
> 4) widget.isAttache() -> true
>
> Appearantly there is a difference between being attached to the Document
> node and Body node.
> Why?
> What to do next to isolate/solve this?

What problem is it you're trying to solve? That's going to dictate the
solution.

> Note: the above statements are called in a DeferedCommand just after the
> widget is added to the RootPanel. It concers an widget that is shown as
> a popup panel (absolute positioned)

Maybe a clickHandler(), but again, what problem is it you're trying to
solve?

Cheers,
jec

Ed Bras

unread,
Jul 19, 2012, 2:29:46 PM7/19/12
to google-we...@googlegroups.com
What problem is it you're trying to solve? That's going to dictate the
solution.

The problem is solved: not using the method  construction: Document.get().isOrHasChild(element).
Instead I use:  Document.get().getDocumentElement().isOrHasChild(element) 

But, the outcome smells like a bug, so maybe somebody can try to reproduce this. If you can reproduce it, it's a bug, otherwise I might have to dig deeper and make an isolated test and hope I can still reproduce it. If so, I can drop the test here. Or maybe it's just some stupid coding mistake I overlook.
Reply all
Reply to author
Forward
0 new messages