elemental2
elemental2 copied to clipboard
elemental2.dom.Window is missing document variable
I'm trying to access the document from a elemental2.dom.HTMLIFrameElement but noticed that elemental2.dom.Window (via HTMLIFrameElement.contentWindow) has no document variable. There is no chance to access an iframe document via elemental2.
This should be possible. Please see more details in the example at https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/contentWindow
I need to solve that via native gwt code:
public final native elemental2.dom.Document document(elemental2.dom.Window contentWindow) /*-{
return contentWindow.document;
}-*/;
Contribution is welcome here.
This can be easily fixed by
- adding the
document
property to theWindow
prototype in google/closure-compiler/blob/master/externs/browser/html5.js
We already have:
import static elemental2.dom.DomGlobal.document; import static elemental2.dom.DomGlobal.window;
You are right but DomGlobal.document and DomGlobal.window are targeting the global document and window objects. The goal is to access document from any Window object that could potentially comes from an IFrame.
I have a question to this problem. So, at the moment I cannot register an event like onclick to an iFrame, is that correct?
Thanks
If you need to access the body, you can still work around this problem by using jsinterop-base:
import jsinterop.base.Js;
HTMLBodyElement iframeBody = Js.asPropertyMap(iframe.contentWindow).get("body");
iframeBody.addEventListener(...)