-
Notifications
You must be signed in to change notification settings - Fork 374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace document.write('<script ...>') with document.createElement('script') #9797
Comments
If the gwt.xml has gwt/dev/core/src/com/google/gwt/core/ext/linker/impl/ResourceInjectionUtil.java Lines 78 to 94 in 38cefc3
AFAICT, your proposed change won't work:
There's definitely room from improvement, and these templates are quite old, but if they don't work for you I'd suggest creating your own linker. But IIRC the xsiframe linker works for browser extensions and shouldn't use |
I was guessing probably |
- replaces PR gwtproject#9814 - due to currentScript not being fully supported, wrapped in conditional - fixes issue gwtproject#9797
GWT version: 2.10.0
Browser (with version): Chrome
Operating System: Version 109.0.5414.119 (Official Build) (x86_64)
Description
I'm using
SingleScriptLinker
to produce a single Javascript file, and the generated JS code contains:Which causes errors when the GWT output JS is used in a Chrome Extension:
According to the latest documentation about
document.write
:https://developer.mozilla.org/en-US/docs/Web/API/Document/write
I'm wondering if it's a good idea to replace the following two lines:
https://github.com/gwtproject/gwt/blob/main/dev/core/src/com/google/gwt/core/linker/SingleScriptTemplate.js#L96-L97
with:
If this makes sense, there are a few other script templates needing similar changes.
https://github.com/gwtproject/gwt/search?q=%24doc.write%28%27%3Cscript&type=code
Steps to reproduce
Inspect the generated GWT Javascript code, you will see
doc.write
in it.Known workarounds
I've tested the new template in a custom linker, which avoided
document.write
in the generated Javascript, hence eliminated such errors in Chrome Extension.Links to further discussions
The text was updated successfully, but these errors were encountered: