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 JSONP error / discrepancy in running between SDK and dart2js #15065
Comments
This comment was originally written by aznaum...@gmail.com I downloaded 1.0 SDK, and example (with different JSON URL input, using Tumblr API) and same behavior as I previously reported -- Dart SDK editor successfully runs but generated compiled javascript (did not try dart2js), just used the GUI generate javascript and then attempted to load page in Chrome browser. Here is the code: import 'dart:html'; void main() { ScriptElement script = new Element.tag("script"); //----- In the SDK runs, but generated javascript produces this error: Uncaught ReferenceError: DartObject is not defined // converts a Dart object to a reference to a native JS object //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! } else if (JS('bool', '#.constructor === DartObject', o)) { |
Not clear if dart2js or dart:js issue. Added Library-JS, Area-Dart2JS, Triaged labels. |
I think I recognize this code from a recent CL from Justin. Set owner to @justinfagnani. |
I'm getting "DartObject is undefined" as well. I'm using the "dart:js" library directly. There's a another bug to remove DartObject and I wonder if this was done incompletely: Looking at the JavaScript output, there are references to DartObject in two functions: But there's no definition of DartObject that I can see. It seems like there should be some end-to-end tests for JavaScript interop with dart2js? |
This comment was originally written by @financecoding Also hitting this error with. Dart Editor version 1.0.3_r30939 (DEV) |
This comment was originally written by youyou3...@gmail.com Also getting this error using "google_maps" via pub. |
This comment was originally written by Burak.Emir...@gmail.com FWIW: I had some previously working code (pre-M4) that I am trying to get up to date again and then ran exactly into this error message. Then I checked the documentation and realized I have to include another script: <script src="packages/browser/interop.js"></script> That solved it for me. |
This comment was originally written by douglas.damo...@gmail.com Also receiving this error with 'dart:js' library. Dart VM version: 1.0.0.10_r30798 (Mon Dec 2 10:26:47 2013) on "macos_x64" |
This comment was originally written by youyou333...@gmail.com <script src="packages/browser/interop.js"></script> has solved the "DartObject is undefined" for me. |
This comment was originally written by @financecoding fwiw, when I hit "DartObject is undefined" I noticed it might of been caused by the order the js scripts was included. Make sure interop.js is the first script. Example: <script src="packages/browser/interop.js"></script> |
This comment was originally written by douglas.da...@gmail.com May I plus +1 Adam's tip here? It resolved my problem. To clarify, I iinterop'd from dart to an existing javascript library. I included <script src="packages/browser/interop.js"></script> after <script src="packages/browser/dart.js"></script> and the dart2js code didn't work until I reversed the order. |
This comment was originally written by @financecoding Agreed, this is one of those odd cases that is hard to remember or know what is the root cause of the issue. Maybe this should be posted on stack overflow and additional logging that could reference potential issue? |
This comment was originally written by jirkad...@gmail.com I posted it on SO as http://stackoverflow.com/questions/21492385/referenceerror-dartobject-is-not-defined |
This comment was originally written by ernest.mi...@gmail.com I noticed dat this solution (adding interop.js) is no longer working for 1.4.0-dev.6.2. packages/browser/interop.js is no longer needed for dart:js. See http://pub.dartlang.org/packages/browser. What does solve it (again) is putting dart.js loading BEFORE loading my projects' dart file. |
This issue was originally filed by aznaum...@gmail.com
Attempting to run this example: https://code.google.com/p/dart/source/browse/branches/bleeding_edge/dart/samples/jsonp/web/index.dart
A code sample of fetching JSON data. Though I am using Tumblr as a JSON source instead -- Tumblr API v1.0.
Had to modify the
document.body.children.add(script)
statement as it causes an error.But interesting, while the code will work in the SDK editor -- it successfully pulls the JSON from the web URL and invokes the callback function -- it will not work with the
dart2js
output in Chrome.(Using build 30107 of dart2js)
Here is the error: http://pbs.twimg.com/media/BZAJk26CYAE9w8Z.jpg
The text was updated successfully, but these errors were encountered: