Search code examples
gwtgwt-elemental

Does GWT elemental use JsType or JSNI Overlays?


I am looking into GWT elemental as a faster way to access the java dom in GWT. However when I look at the source code for the maven dependencies, all I see is js overlays. For instance:

public class JsNode extends JsElementalMixinBase  implements Node {
  protected JsNode() {}

  public final native JsNamedNodeMap getAttributes() /*-{
    return this.attributes;
  }-*/;

  public final native String getBaseURI() /*-{
    return this.baseURI;
  }-*/;

  public final native JsNodeList getChildNodes() /*-{
    return this.childNodes;
  }-*/;

  public final native JsNode getFirstChild() /*-{
    return this.firstChild;
  }-*/;

  public final native JsNode getLastChild() /*-{
    return this.lastChild;
  }-*/;
....

This isn't too far off from what is in the default gwt xml dom. What am I missing here?

Thanks!


Solution

  • Elemental v1, which is no longer updated regularly, uses JSOs and JSNI, as that was the only option at the time.

    Elemental v2 uses JsInterop, the new, future-proofed way of describing JS objects from within Java code. The sources (and issue tracking) is at https://github.com/google/elemental2/. You can find elemental2 in maven by searching for the groupId com.google.elemental2: http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.google.elemental2%22

    https://github.com/google/jsinterop-generator is the tool used to autogenerate elemental2, and can in theory be used on any other JS library to let GWT applications make use of it. I personally have not had a lot of luck getting it working, but the primary purpose of the tool is still to generate elemental2 sources, so this will continue improving as people use it.