About the iframe instanceof problem, I think this is due to the fact that
JavaScript prototypes do not cross frame boundaries (for security and
privacy reasons). So even in JavaScript, the instanceof operator would not
work.

You can try this example :


<html>
<head></head>
<body>
<iframe id="frame" src="frame.html" frameborder="0"></iframe>

<script>
let frame = document.querySelector("#frame");
let doc = frame.contentDocument;

let a = doc instanceof HTMLDocument;

console.log(`reality check : ${a}`);
</script>
</body>
</html>


If the HTMLDocument class would have @JsType( isNative=true,
namespace=JsPackage.GLOBAL, name="Object" ) annotation, the above snippet
would have worked as expected.

The suggested work around (jsni method) might work, the idea is to bypass
the GWT compiler generated cast checks.

Thanks

Arnaud



Le mer. 31 mai 2017 à 12:47, <
google-web-toolkit-contributors@googlegroups.com> a écrit :

> google-web-toolkit-contributors@googlegroups.com
> <https://groups.google.com/forum/?utm_source=digest&utm_medium=email#!forum/google-web-toolkit-contributors/topics>
>  Google
> Groups
> <https://groups.google.com/forum/?utm_source=digest&utm_medium=email/#!overview>
> <https://groups.google.com/forum/?utm_source=digest&utm_medium=email/#!overview>
> Topic digest
> View all topics
> <https://groups.google.com/forum/?utm_source=digest&utm_medium=email#!forum/google-web-toolkit-contributors/topics>
>
>    - Elemental2 1.0.0-beta-1 and casting behaves unexpectedly
>    <#m_-2436713973876021791_m_7201606050167563021_group_thread_0> - 3
>    Updates
>    - Elemental2 source code on github
>    <#m_-2436713973876021791_m_7201606050167563021_group_thread_1> - 2
>    Updates
>
> Elemental2 1.0.0-beta-1 and casting behaves unexpectedly
> <http://groups.google.com/group/google-web-toolkit-contributors/t/178d53b02c0326f5?utm_source=digest&utm_medium=email>
> Daniel Harezlak <dharez...@gmail.com>: May 30 11:23PM -0700
>
> Hi, I have the following code using elemental2-dom:
>
> HTMLIFrameElement frame = (HTMLIFrameElement) DomGlobal.document.
> createElement("iframe");
> HTMLDocument doc = (HTMLDocument) frame.contentDocument; //throws
> java.lang.ClassCastException
>
> The second line throws an exception although I am quite sure that the
> returned element is an HTMLDocument because when I log it in the JS
> console
> I get "[object HTMLDocument]". The first line works fine. What is strange
> the exception is only thrown in Chrome both in SDM and production modes.
> In
> Firefox it works just fine. Any thoughts?
> Daniel Harezlak <dharez...@gmail.com>: May 31 12:25AM -0700
>
> The way to work around it is to use a native method:
>
> private static native HTMLDocument getHtmlDocument(HTMLIFrameElement
> frame)
> /*-{
> return frame.contentDocument;
> }-*/;
>
> Is this required?
>
> On Wednesday, May 31, 2017 at 8:23:20 AM UTC+2, Daniel Harezlak wrote:
> gwtte...@gmail.com: May 31 02:19AM -0700
>
> How about using jsinterop.base.Js.cast() for the casing instead? - see:
> https://groups.google.com/forum/#!topic/Google-Web-Toolkit/0XGv7EhDFmc
>
> On Wednesday, May 31, 2017 at 7:23:20 AM UTC+1, Daniel Harezlak wrote:
> Back to top <#m_-2436713973876021791_m_7201606050167563021_digest_top>
> Elemental2 source code on github
> <http://groups.google.com/group/google-web-toolkit-contributors/t/eb4664520f6087c2?utm_source=digest&utm_medium=email>
> Daniel Harezlak <dharez...@gmail.com>: May 30 11:04PM -0700
>
> Hi, it looks like issues are disabled for the
> https://github.com/google/elemental2 project.
>
> On Saturday, May 20, 2017 at 12:34:09 AM UTC+2, Julien Dramaix wrote:
>
> Julien Dramaix <julien.dram...@gmail.com>: May 31 06:40AM
>
> I've enabled the issue tab.
>
> On Tue, May 30, 2017 at 11:04 PM Daniel Harezlak <dharez...@gmail.com>
> wrote:
>
> Back to top <#m_-2436713973876021791_m_7201606050167563021_digest_top>
> You received this digest because you're subscribed to updates for this
> group. You can change your settings on the group membership page
> <https://groups.google.com/forum/?utm_source=digest&utm_medium=email#!forum/google-web-toolkit-contributors/join>
> .
> To unsubscribe from this group and stop receiving emails from it send an
> email to google-web-toolkit-contributors+unsubscr...@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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit-contributors/CANjaDnccS5cs-ee6dkJyLzRz312sJcB2Bky2DN-YhSJXLZzikg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to