ScriptInjector seems to be broken (2.8-SNAPSHOT)

279 views
Skip to first unread message

stuckagain

unread,
Sep 5, 2016, 7:40:38 AM9/5/16
to GWT Contributors
It looks like the ScriptInjector is no longer working properly in the snapshot.

I had code like this:

ScriptInjector.fromString(pBundle.d3JS().getText()).inject();

To load D3 using a TextResource.


Since today (just came back after 2 weeks of holidays) the D3 object is no longer available in $wnd.


I changed the code to this:

ScriptInjector.fromString(pBundle.d3JS().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject();


and then it works.


stuckagain

unread,
Sep 5, 2016, 7:58:51 AM9/5/16
to GWT Contributors

I am using JsInterop to interact with the D3 library, Using namespace=JsPackage.GLOBAL. I guess I will have to use "window" instead ?

Jens

unread,
Sep 5, 2016, 12:29:48 PM9/5/16
to GWT Contributors
Hm wondering how it ever worked for you as JsInterop usually qualifies JS code with $wnd but your D3.js has been injected into the GWT iframe. So AFAICT with JsInterop you would had to use TOP_WINDOW anyways. You can make it work within the GWT iframe but then you can't use JsPackage.GLOBAL but use a namespace that points to the iframe content window.


So it looks like this behavior has changed? But yes you would need to use "window" now to references the iframe's content window if you inject the code into the iframe.

-- J.

stuckagain

unread,
Sep 6, 2016, 5:43:01 AM9/6/16
to GWT Contributors
It was working fine before.

Since it looks like JsInterop has changed recently (and it is still in beta) I will just update my code to either inject in the TOP_WINDOW or I try it with using window as namespace.

Goktug Gokdogan

unread,
Sep 6, 2016, 1:28:53 PM9/6/16
to google-web-toolkit-contributors
It is surprising as Jens pointed out, we always qualified references with $wnd until https://gwt-review.googlesource.com/#/c/15520/ (submitted 5 weeks ago). So it shouldn't have worked earlier if you were not injecting it to TOP_WINDOW.
If it worked earlier, then we unintentionally fixed a bug. Could you double check if this was working before so we can see if there are some other unintended behavior change introduced somewhere else?

--
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 google-web-toolkit-contributors+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit-contributors/7862784c-854a-4bb1-85c0-2b7734a984d3%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

David

unread,
Sep 8, 2016, 6:21:20 AM9/8/16
to google-web-tool...@googlegroups.com
I'm sure that it worked before. I'm also seeing some other issues where I am using JsInterop to interact with some generated HTML - but I am still investigating if that is due to changes in GWT or in our codebase.

I did not work on this project for about 8 weeks, so I have quite a backlog to go through.

On Tue, 6 Sep 2016 at 19:28, 'Goktug Gokdogan' via GWT Contributors <google-web-tool...@googlegroups.com> wrote:
It is surprising as Jens pointed out, we always qualified references with $wnd until https://gwt-review.googlesource.com/#/c/15520/ (submitted 5 weeks ago). So it shouldn't have worked earlier if you were not injecting it to TOP_WINDOW.
If it worked earlier, then we unintentionally fixed a bug. Could you double check if this was working before so we can see if there are some other unintended behavior change introduced somewhere else?
On Tue, Sep 6, 2016 at 2:43 AM, stuckagain <david...@gmail.com> wrote:
It was working fine before.

Since it looks like JsInterop has changed recently (and it is still in beta) I will just update my code to either inject in the TOP_WINDOW or I try it with using window as namespace.


On Monday, September 5, 2016 at 6:29:48 PM UTC+2, Jens wrote:
Hm wondering how it ever worked for you as JsInterop usually qualifies JS code with $wnd but your D3.js has been injected into the GWT iframe. So AFAICT with JsInterop you would had to use TOP_WINDOW anyways. You can make it work within the GWT iframe but then you can't use JsPackage.GLOBAL but use a namespace that points to the iframe content window.


So it looks like this behavior has changed? But yes you would need to use "window" now to references the iframe's content window if you inject the code into the iframe.

-- 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 google-web-toolkit-co...@googlegroups.com.

--
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 google-web-toolkit-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit-contributors/CAN%3DyUA0RioQk7GatwdbkvwZKT6gKDEmB0daytVoKa9a%3DnGUd3A%40mail.gmail.com.

David

unread,
Sep 8, 2016, 6:21:20 AM9/8/16
to google-web-tool...@googlegroups.com
I was depending on JsInterop Global.document to get access to UI components generated by my template engine.
The Global object is now scoped window, so I guess it is accessing the wrong document as well ?

Goktug Gokdogan

unread,
Sep 8, 2016, 5:17:54 PM9/8/16
to google-web-toolkit-contributors
Global object is not scoped to window unless you explicitly say "window"; so it should be $wnd by default.

On Wed, Sep 7, 2016 at 2:50 AM, David <david...@gmail.com> wrote:
I was depending on JsInterop Global.document to get access to UI components generated by my template engine.
The Global object is now scoped window, so I guess it is accessing the wrong document as well ?
On Wed, 7 Sep 2016 at 11:40, David <david...@gmail.com> wrote:
I'm sure that it worked before. I'm also seeing some other issues where I am using JsInterop to interact with some generated HTML - but I am still investigating if that is due to changes in GWT or in our codebase.

I did not work on this project for about 8 weeks, so I have quite a backlog to go through.

On Tue, 6 Sep 2016 at 19:28, 'Goktug Gokdogan' via GWT Contributors <google-web-toolkit-contri...@googlegroups.com> wrote:
It is surprising as Jens pointed out, we always qualified references with $wnd until https://gwt-review.googlesource.com/#/c/15520/ (submitted 5 weeks ago). So it shouldn't have worked earlier if you were not injecting it to TOP_WINDOW.
If it worked earlier, then we unintentionally fixed a bug. Could you double check if this was working before so we can see if there are some other unintended behavior change introduced somewhere else?
On Tue, Sep 6, 2016 at 2:43 AM, stuckagain <david...@gmail.com> wrote:
It was working fine before.

Since it looks like JsInterop has changed recently (and it is still in beta) I will just update my code to either inject in the TOP_WINDOW or I try it with using window as namespace.


On Monday, September 5, 2016 at 6:29:48 PM UTC+2, Jens wrote:
Hm wondering how it ever worked for you as JsInterop usually qualifies JS code with $wnd but your D3.js has been injected into the GWT iframe. So AFAICT with JsInterop you would had to use TOP_WINDOW anyways. You can make it work within the GWT iframe but then you can't use JsPackage.GLOBAL but use a namespace that points to the iframe content window.


So it looks like this behavior has changed? But yes you would need to use "window" now to references the iframe's content window if you inject the code into the iframe.

-- 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 google-web-toolkit-contributors+unsubscribe@googlegroups.com.

--
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 google-web-toolkit-contributors+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "GWT Contributors" group.

David

unread,
Sep 9, 2016, 4:34:51 AM9/9/16
to google-web-tool...@googlegroups.com
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 ?



On Thu, Sep 8, 2016 at 11:17 PM 'Goktug Gokdogan' via GWT Contributors <google-web-tool...@googlegroups.com> wrote:
Global object is not scoped to window unless you explicitly say "window"; so it should be $wnd by default.

On Wed, Sep 7, 2016 at 2:50 AM, David <david...@gmail.com> wrote:
I was depending on JsInterop Global.document to get access to UI components generated by my template engine.
The Global object is now scoped window, so I guess it is accessing the wrong document as well ?
On Wed, 7 Sep 2016 at 11:40, David <david...@gmail.com> wrote:
I'm sure that it worked before. I'm also seeing some other issues where I am using JsInterop to interact with some generated HTML - but I am still investigating if that is due to changes in GWT or in our codebase.

I did not work on this project for about 8 weeks, so I have quite a backlog to go through.

On Tue, 6 Sep 2016 at 19:28, 'Goktug Gokdogan' via GWT Contributors <google-web-tool...@googlegroups.com> wrote:
It is surprising as Jens pointed out, we always qualified references with $wnd until https://gwt-review.googlesource.com/#/c/15520/ (submitted 5 weeks ago). So it shouldn't have worked earlier if you were not injecting it to TOP_WINDOW.
If it worked earlier, then we unintentionally fixed a bug. Could you double check if this was working before so we can see if there are some other unintended behavior change introduced somewhere else?
On Tue, Sep 6, 2016 at 2:43 AM, stuckagain <david...@gmail.com> wrote:
It was working fine before.

Since it looks like JsInterop has changed recently (and it is still in beta) I will just update my code to either inject in the TOP_WINDOW or I try it with using window as namespace.


On Monday, September 5, 2016 at 6:29:48 PM UTC+2, Jens wrote:
Hm wondering how it ever worked for you as JsInterop usually qualifies JS code with $wnd but your D3.js has been injected into the GWT iframe. So AFAICT with JsInterop you would had to use TOP_WINDOW anyways. You can make it work within the GWT iframe but then you can't use JsPackage.GLOBAL but use a namespace that points to the iframe content window.


So it looks like this behavior has changed? But yes you would need to use "window" now to references the iframe's content window if you inject the code into the iframe.

-- 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 google-web-toolkit-co...@googlegroups.com.

--
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 google-web-toolkit-co...@googlegroups.com.

--
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 google-web-toolkit-co...@googlegroups.com.
--
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 google-web-toolkit-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit-contributors/CAN%3DyUA1cpbN2rOA0Ka%3D%2ByqiDMU2-UcFcWwVp4ueMc8Ms20r4-g%40mail.gmail.com.

Jens

unread,
Sep 9, 2016, 6:13:16 AM9/9/16
to GWT Contributors

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.

David

unread,
Sep 9, 2016, 8:44:14 AM9/9/16
to google-web-tool...@googlegroups.com
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 ?


--
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 google-web-toolkit-co...@googlegroups.com.

Jens

unread,
Sep 9, 2016, 9:51:05 AM9/9/16
to GWT Contributors
Ok just tried it myself.

Created a new, fresh project having <div id="hello">world</div> in my host page using

public void onModuleLoad() {
 
Global.window.alert("Element found: " + (Global.document.getElementById("hello") != null));
}


GWT 2.8 RC2 returns true

_.onModuleLoad_4_g$ = function onModuleLoad_3_g$(){
 
($clinit_Global_0_g$() , $wnd.window.window).alert('Element found: ' + jsNotEquals_0_g$(($clinit_Global_0_g$() , $wnd.window.document).getElementById('hello'), null));
}



GWT 2.8 SNAPSHOT (09.09.2016) returns false

_.onModuleLoad_4_g$ = function onModuleLoad_3_g$(){
 
($clinit_Global_0_g$() , window).alert('Element found: ' + jsNotEquals_0_g$(($clinit_Global_0_g$() , document).getElementById('hello'), null));
}



So I guess its a bug in GWT 2.8 SNAPSHOT as I think the JS output of GWT 2.8 SNAPSHOT should be that way it is above if @JsType(isNative = true, namespace = "window") is used. However elemental2 uses JsPackage.GLOBAL as namespace.


-- J.

Thomas Broyer

unread,
Sep 9, 2016, 10:01:19 AM9/9/16
to GWT Contributors
Can you file an issue and ping Daniel (by mail or hangout) to delay the RC3 a bit? (if not already too late, as it's 4pm cest)

Jens

unread,
Sep 9, 2016, 10:12:00 AM9/9/16
to GWT Contributors

Can you file an issue and ping Daniel (by mail or hangout) to delay the RC3 a bit? (if not already too late, as it's 4pm cest)

Done.

Daniel Kurka

unread,
Sep 9, 2016, 10:30:33 AM9/9/16
to GWT Contributors, gok...@google.com, rlu...@google.com
+Goktug Gokdogan +Roberto Lublinerman  Should we be holding RC3, I guess so right?

On Fri, Sep 9, 2016 at 4:12 PM Jens <jens.ne...@gmail.com> wrote:

Can you file an issue and ping Daniel (by mail or hangout) to delay the RC3 a bit? (if not already too late, as it's 4pm cest)

Done.

--
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 google-web-toolkit-co...@googlegroups.com.

Colin Alworth

unread,
Sep 9, 2016, 11:04:38 AM9/9/16
to GWT Contributors, gok...@google.com, rlu...@google.com
Another issue at may warrant attention - https://github.com/gwtproject/gwt/issues/9424. This was brought up some time ago, but wasn't reduced to be reproducible until now (which is funny, given how minimal the test case is).

Goktug Gokdogan

unread,
Sep 9, 2016, 1:33:51 PM9/9/16
to Colin Alworth, GWT Contributors, rlu...@google.com
We should hold up the release. There is another path around arrays as well.

On Fri, Sep 9, 2016 at 8:04 AM, Colin Alworth <nilo...@gmail.com> wrote:
Another issue at may warrant attention - https://github.com/gwtproject/gwt/issues/9424. This was brought up some time ago, but wasn't reduced to be reproducible until now (which is funny, given how minimal the test case is).

On Fri, Sep 9, 2016 at 9:30 AM 'Daniel Kurka' via GWT Contributors <google-web-toolkit-contri...@googlegroups.com> wrote:
+Goktug Gokdogan +Roberto Lublinerman  Should we be holding RC3, I guess so right?

On Fri, Sep 9, 2016 at 4:12 PM Jens <jens.ne...@gmail.com> wrote:

Can you file an issue and ping Daniel (by mail or hangout) to delay the RC3 a bit? (if not already too late, as it's 4pm cest)

Done.

--
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 google-web-toolkit-contributors+unsubscribe@googlegroups.com.

--
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 google-web-toolkit-contributors+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages