Skip to content

js-interop: Breaking bug calling methods on JS class named 'Node' #28005

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

Closed
theefer opened this issue Dec 6, 2016 · 3 comments
Closed

js-interop: Breaking bug calling methods on JS class named 'Node' #28005

theefer opened this issue Dec 6, 2016 · 3 comments
Labels
web-js-interop Issues that impact all js interop

Comments

@theefer
Copy link

theefer commented Dec 6, 2016

I've encountered a confusing issue in Dartium when trying to interoperate with a JS library ProseMirror that exposes instances of a class named Node.

I've defined an interop definition around it like so:

@JS()
class Node {
  external bool get isText;
  external String get text;

Given node an instance of that Node class (let's call it pm.Node for clarity), calling node.isText works fine, however calling node.text throws the following exception:

EXCEPTION: Unhandled exception:
Not a valid Node
#0      BlinkNode.textContent_Getter_ (dart:_blink:11270)
#1      Node.text (dart:html:28048)

Apparently, the VM gets sufficiently confused about types that it tries to call the text method from dart:html's Node class (!?!), and then complains it's not an instance of that class. I can also confirm that this error occurs when trying to call any dart:html Node method on my pm.Node instance, regardless of whether it exists on pm.Node or not. In contrast, trying to call a method or getter that doesn't exists on either throws the expected NoSuchMethodError: Class 'Node' has no instance getter '___'..

Fortunately, after a few hours of head scratching I figured out that I can rename the getter to JS$text to work around this issue, but it's still a very confusing and annoying bug.

This may be related to #25785, which was fixed recently.

@thso
Copy link

thso commented Dec 6, 2016

@jacob314

@kevmoo kevmoo added the web-js-interop Issues that impact all js interop label Dec 6, 2016
@theefer
Copy link
Author

theefer commented Dec 7, 2016

We're also getting a lot of noisy errors from Dartium on the console, which never seemed to cause a problem, but might be related to this:

Return value for method: text is Node which is inconsistent with all typed JS interop definitions for method text.
Return value for method: node is Node which is inconsistent with all typed JS interop definitions for method node.

(lack of context of which Node is meant here may hide the fact that the wrong one is found/expected, as per the bug above)

There stacktrace references the VM so no luck tracing it sadly.

@kevmoo
Copy link
Member

kevmoo commented Mar 26, 2018

Dartium will not be supported in Dart2

@kevmoo kevmoo closed this as completed Mar 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
web-js-interop Issues that impact all js interop
Projects
None yet
Development

No branches or pull requests

3 participants