-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
js-interop: document limitations with ES6 #39995
Comments
The problem is that with We either need to document that these aren't accessible through Dart, or find a new way to access them. cc @sigmundch |
You are right, that didn't occure to me. And the same goes for ES2015 classes as I have noticed. It might be worth mentioning that only ES5 is fully supported and that Babel should be used. |
minor update: I just updated the title and merged a few issues here to track them all in one place. ES6
Note that you shouldn't have to convert to ES5 with babel, it would be sufficient to expose the symbols that can't be hoisted. For example: class MyClass {...}
window.MyClass = MyClass; would work too. |
I am looking for the solution for the issue #35737. It directed me here for more discussion on the issue. Is there any suggestion for that issue solution. Sorry actual issue has been marked as closed. So keeping the comment here for solution. Thanks in advance. |
@RaghuMudem - the example in #35737 was exporting an ES6 class: export class HelloWorld {
sayHello() {
return "HelloWorld"
}
} So the suggestion in #39995 (comment) applies here. That is, add in JavaScript an extra line that actually exposes the class definition as a top-level member on the window: export class HelloWorld {
sayHello() {
return "HelloWorld"
}
}
window.HelloWorld = HelloWorld; This will make it possible for JS-interop to find that definition. Was this the pattern you were looking for? |
Hi @sigmundch, Thanks for your reply. And the same video is able to find initApp method. initApp method is called with the following code.
And my complete javascript code is here. I also added comments to make it clear on the problematic areas.
Here is the console logs:
Would be very helpful if anyone can suggest me to get the video element in the places mentioned above. |
I found a workaround for this. Posting the clue here for others who has the similar problem. Description about the solution:
Hope this clue can help for someone who is working for Flutter-web-iframe-video-js-interop combination :) |
I am getting dart.global.MyClass is not a constructor if I add script elements dynamically but works fine if script is added directly to index.html. I have requirement to add scripts dynamically only. Can you please help me with the same? |
@MaryaBelanger @srujzs - FYI - another user hit this issue again this week. It may be worth adding a section about this in some of our upcoming site changes (maybe under some kind of FAQ?) |
Describe the issue you're seeing
External getters don't work with JS
let
andconst
declarations.It does work, however, with
var
declaration.Does it happen in Dartium or when compiled to JavaScript?
Compile to JavaScript with
webdev build
.dart --version
2.7
pubspec.lock
0.6.1+1
Failing code:
Working code:
The text was updated successfully, but these errors were encountered: