javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Element.java
branchfx
changeset 1011 9cc253aa9405
parent 978 5aa8bc3c98b0
     1.1 --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Element.java	Sun Apr 14 11:51:58 2013 +0200
     1.2 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Element.java	Thu Apr 18 16:58:55 2013 +0200
     1.3 @@ -47,14 +47,34 @@
     1.4          body="var e = window.document.getElementById(el._id());\n"
     1.5             + "e[property] = value;\n"
     1.6      )
     1.7 -    static native void setAttribute(Element el, String property, Object value);
     1.8 +    static void setAttribute(Element el, String property, Object value) {
     1.9 +        JSObject js = (JSObject) web().executeScript("(function () {"
    1.10 +            + "  var x = {}; "
    1.11 +            + "  x.setAttribute = function(id, property, value) { "
    1.12 +            + "    var e = window.document.getElementById(id);\n"
    1.13 +            + "    e[property] = value;"
    1.14 +            + "  };"
    1.15 +            + "  return x;"
    1.16 +            + "})()");
    1.17 +        js.call("setAttribute", el.id, property, value);
    1.18 +    }
    1.19  
    1.20      @JavaScriptBody(
    1.21          args={"el", "property"},
    1.22          body="var e = window.document.getElementById(el._id());\n"
    1.23             + "return e[property];\n"
    1.24      )
    1.25 -    static native Object getAttribute(Element el, String property);
    1.26 +    static Object getAttribute(Element el, String property) {
    1.27 +        JSObject js = (JSObject) web().executeScript("(function () {"
    1.28 +            + "  var x = {}; "
    1.29 +            + "  x.getAttribute = function(id, property) { "
    1.30 +            + "    var e = window.document.getElementById(id);\n"
    1.31 +            + "    return e[property];"
    1.32 +            + "  };"
    1.33 +            + "  return x;"
    1.34 +            + "})()");
    1.35 +        return js.call("getAttribute", el.id, property);
    1.36 +    }
    1.37      
    1.38      @JavaScriptBody(
    1.39          args={"el"},