I'm sure my stuff was working fine with JsInterop 1.0 but with JsInterop
2.0 the only solution seems to be to use Global.top.window.document
As far as I remember I had it working somewhere half of July - but I might
be wrong. Can I force in maven to take a very specific snapshot version of
GWT 2.8.0, then I could double check ?

>From what you explain it seems like Global.window should have worked. But I
have this in my html:

<div id="test">I'm here!</div>

Then when I try these:
Global.document.getElementById("test") -> null
Global.window.document.getElementById("test") -> null
Global.top.document.getElementById("test") -> [object HtmlDivElement]

Is this really how it should be ? I cannot use top since my app could be
embedded in an IFrame. I would have expected Global.document.getElementId
to have worked but it does not.

Anyway, maybe its because there is not enough docs available yet that I am
confused. Maybe it was accidentally working before and all this is just how
it is supposed to be ?


On Fri, Sep 9, 2016 at 12:13 PM Jens <[email protected]> wrote:

>
> This scoping is all very confusing :-).
>>
>> Anyway, this is what I am seeing with Elemental2:
>> - I have an application that generates HTML using a custom templating
>> system.
>> - I then put the HTML string in an Element with setInnerSafeHtml.
>> - After this I use Element2 to bind to the generated html. For that I was
>> using Global.document.getElementById(...).
>>
>> This used to work, but since a few weeks this stopped working.
>>
>> I now have to use Global.window.top.document.getElementById(...) to get
>> access to the ui dom nodes that I generated.
>>
>> Is this how it is supposed to be ? I was probably making the wrong
>> assumptions before ?
>>
>
> No. Elemental2's Global class uses @JsType(isNative = true, name =
> "window", namespace = JsPackage.GLOBAL) which translates to $wnd.window
> because JsInterop qualifies everything with $wnd (unless
> namespace="window" has been set as of the commit you have referenced
> before), JsPackage.GLOBAL is an empty namespace and window is the name.
>
> Are you sure nothing has changed in your app ?! I don't think something
> has changed in GWT as such (breaking) changes would normally cause more
> posts on gwt-contrib / gwt-user.
>
> -- J.
>
> --
> You received this message because you are subscribed to the Google Groups
> "GWT Contributors" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-web-toolkit-contributors/9b7a6321-c9ca-44a8-bd8d-01e6dc113f13%40googlegroups.com
> <https://groups.google.com/d/msgid/google-web-toolkit-contributors/9b7a6321-c9ca-44a8-bd8d-01e6dc113f13%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit-contributors/CABrJHW2JDzPyAHXD6MVgazyPGb_5t8tugTJqKrR4vbzVN5XCOQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to