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
dart:js library doesn't work in Dartium #13215
Comments
Looks like the issue is that I left out a script tag: <script src="packages/browser/interop.js"></script> The documentation for 'package:js/js.dart' explains this, but the 'dart:js' library's documentation doesn't. (Also, perhaps improve the error message for this case?) |
Additional issues: var jsElt = js.context["document"].callMethod("getElementById", [id]); It seems like it might be nice to write it as: var jsElt = js.context.callMethod("document.getElementById", [id]); This might even be more efficient, since there would only be one round trip and no intermediate proxies would need to be created. Perhaps array access could be implemented as well, sort of like using query() to find a DOM node. (I can break those out into bugs if needed, but it sounds like this library is going to change anyway.) |
Set owner to @justinfagnani. |
This comment was originally written by @a14n Comments on your additional issues : On your feature request : with this syntax there could be some edge cases to handle. For instance if a "document.getElementById" variable had been defined ( e.g. There is also a CL to add Array support that is waiting to be merged (https://chromiumcodereview.appspot.com/23291005/). |
Added Library-JS label. |
Hi, Is this issue still valid? |
The original bug? no. There is a possible feature request with passing path/index expressions to callMethod(). |
== jstest.html ==
<!DOCTYPE html>
<html>
<head>
<title>jstest</title>
</head>
<body>
<script type="application/dart" src="jstest.dart"></script>
<script src="packages/browser/dart.js"></script>
</body>
</html>
== jstest.dart ==
library jstest;
import 'dart:js' as js;
main() {
print("main called");
js.context.callMethod("alert", ["hello"]);
print("main done");
}
== output in Dartium ==
main called
Breaking on exception: The null object does not have a method 'callMethod'.
Exception: The null object does not have a method 'callMethod'.
NoSuchMethodError : method not found: 'callMethod'
Receiver: null
Arguments: ["alert", GrowableObjectArray len:1]
Object.noSuchMethod (dart:core-patch/object_patch.dart:20:25)
main (http://127.0.0.1:3030/Users/skybrian/dart/bugtest/web/jstest.dart:7:24)
main (http://127.0.0.1:3030/Users/skybrian/dart/bugtest/web/jstest.dart:7:24)
== output in JavaScript ==
main called
main done
Dart Editor version 0.7.1_r27025
Dart SDK version 0.7.1.0_r27025
The text was updated successfully, but these errors were encountered: