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
Uncaught TypeError when compiling working Dart project to js. #15125
Comments
This comment was originally written by michael.haubenwa...@gmail.com This might be some timing problem with querySelector. I had the same problem and after moving the script element with the compiled JS from HEAD to the bottom of the document BODY it worked for me again. |
This comment was originally written by michael.haubenwa...@gmail.com When compiling the sample content for a dart web application, this comes up in the resulting JS file: TypedData_ListMixin_FixedLengthListMixin: {"": "TypedData_ListMixin+FixedLengthListMixin;", $asList: null}}], reverseText: function($event) { Question is, if "t1.toString;" is used to test for a null/unassigned value of "t1" or is just test output and not removed from the compiler? |
Added Area-Dart2JS, Triaged labels. |
Pete: I believe that dart2js is doing the right thing by executing main before the rest of the DOM is parsed (leading to querySelector returning null). Michael: re #3, yes dart2js will insert t1.toString to check for null. But in this case it seems redundant (as it is preceded by t1.textContent). Set owner to @blois. |
Correct- the execution is occurring in the head. The proper fix would be to modify mpismobile.html to move the Dart script to the end of the body tag. I just opened 15229 against Polymer build- it should either be adding a defer attribute to the generated JS script, or it should add a warning when the script is not at the end of the body (or both). Added AsDesigned label. |
This comment was originally written by cyrill....@gmail.com Thanks for looking into this issue. I just tried out your described workaround and moved <script type="application/dart" src="mpismobile.dart"></script> to the bottom of mpismobile.html. Tried it with following to examples. <html> or <html> In both cases I get this js error. [10:50:36.800] : NoSuchMethodError : method not found: 'Symbol("map")' It's a different error .. so shall I open a different issue here? Or post my problem somewhere else? |
cc @blois. |
I've filed issue #15236 regarding the redundant null check. |
PolymerDart is deprecated. |
This issue was originally filed by cyrill.zadr...@gmail.com
What steps will reproduce the problem?
What is the expected output? What do you see instead?
It should show a map with default location in zurich. Map stays grey and in browser console following error is shown:
Uncaught TypeError: Cannot call method 'get$map' of null mpismobile.html_bootstrap.dart.js:142561
What version of the product are you using? On what operating system?
Dart Editor version 1.0.0_r30187 (DEV)
Dart SDK version 1.0.0.3_r30187
Chrome 31
Firefox 25
IE 10
Please provide any additional information below.
Dart project example can be also found on https://github.com/thomasfrick1/mpis/tree/dart2js-problem/MpisMobile
Attachment:
MpisMobile.zip (5.07 MB)
The text was updated successfully, but these errors were encountered: