{"action":"opened","issue":{"url":"https://api.github.com/repos/dart-lang/sdk/issues/26532","repository_url":"https://api.github.com/repos/dart-lang/sdk","labels_url":"https://api.github.com/repos/dart-lang/sdk/issues/26532/labels{/name}","comments_url":"https://api.github.com/repos/dart-lang/sdk/issues/26532/comments","events_url":"https://api.github.com/repos/dart-lang/sdk/issues/26532/events","html_url":"https://github.com/dart-lang/sdk/issues/26532","id":156767271,"number":26532,"title":"js-interop: Breaking issue with all JS classes named 'Node'","user":{"login":"theefer","id":36964,"avatar_url":"https://avatars.githubusercontent.com/u/36964?v=3","gravatar_id":"","url":"https://api.github.com/users/theefer","html_url":"https://github.com/theefer","followers_url":"https://api.github.com/users/theefer/followers","following_url":"https://api.github.com/users/theefer/following{/other_user}","gists_url":"https://api.github.com/users/theefer/gists{/gist_id}","starred_url":"https://api.github.com/users/theefer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theefer/subscriptions","organizations_url":"https://api.github.com/users/theefer/orgs","repos_url":"https://api.github.com/users/theefer/repos","events_url":"https://api.github.com/users/theefer/events{/privacy}","received_events_url":"https://api.github.com/users/theefer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-05-25T14:36:53Z","updated_at":"2016-05-25T14:36:53Z","closed_at":null,"body":"We have come across a gnarly issue in the Dart interop with JavaScript. In short, it doesn't seem possible to wrap any JS class named `Node`, even if it has been declared with an `@JS()` interface and isolated in a dedicated namespace, due to a conflict with dart:html's Node.\r\n\r\n## Recipe to reproduce\r\n\r\nWe have been able to reproduce the issue with a reduced example:\r\n* [JavaScript \"library\"](https://gist.github.com/theefer/63fd78e947c020b545e75c057ac22aa9)\r\n* [Dart wrapper definition](https://gist.github.com/theefer/5a7629c88bdc766294d4badecd1e80ba)\r\n\r\nAfter loading both the above, we can run the following code: \r\n\r\n``` dart\r\nfinal a = getFooBar();\r\nprint(a.test1());\r\n// prints 'FooBar.test1'\r\n\r\nfinal b = getNode();\r\nprint(b.test2());\r\n// throws \"NoSuchMethodError: method not found: 'test2$0' (J.getInterceptor$x(...).test2$0 is not a function)\"\r\n```\r\n\r\n## Details\r\n\r\nThe error is manifesting for us when trying to use [ProseMirror](http://prosemirror.net/) from Dart, specifically uses of its [Node](https://prosemirror.net/ref.html#Node) class (I can provide an internal code reference if you ping me at sebcevey@). Note that all other wrapped classes (e.g. `Schema`, `ProseMirror`, etc) behave as expected; only `Node` is failing.\r\n\r\nWhen running off the Dart code in Dartium, the code executes but we get the following warning on the console:\r\n\r\n> Return value for method: node is Node which is inconsistent with all typed JS interop definitions for method node.\r\n\r\nWhen running off a compiled JS bundle, the code fails with the following error:\r\n\r\n> NoSuchMethodError: method not found: 'get$content' (J.getInterceptor$x(...).get$content is not a function)\r\n\r\nWe have been able to track down the issue to the interceptor resolution logic, which incorrectly identifies ProseMirror's Node class with the dart:html Node class. This is because the interceptor lookups fall back to the `typeNameInChrome` function which returns the `fn.constructor.name` string (in this case 'Node'), which then gets matched up with Dart's interface for dart:html Node. We can see that erroneous interceptor on the record patched onto the ProseMirror Node prototype.\r\n\r\nIn contrast, other wrapped classes which *do* work as expected don't match any known names and receive `UnknownJavaScriptObject_methods` as interceptor. Note that we weren't sure whether this is the expected code path?\r\n\r\nCan you please advise whether this is a known issue, and if there is any workaround we can use?"}}
{"actor":{"display_login":"theefer"}}