Closed
Description
@JS()
library js_interop_dollar_test;
import 'package:js/js.dart';
@JS()
external void $jsMethod();
main() {
$jsMethod();
}
The above code works compiled to JS, but in Dartium, in throws this error:
Exception: No top-level getter or setter 'jsMethod' declared.
NoSuchMethodError: method not found: 'jsMethod'
Receiver: top-level
Arguments: [...]
Note the .dart_js_interop_patch.dart
file:
import 'dart:js' as js_library;
/**
* Placeholder object for cases where we need to determine exactly how many
* args were passed to a function.
*/
const _UNDEFINED_JS_CONST = const Object();
patch $jsMethod() {
return js_library.JsNative.callMethod(js_library.context, '$jsMethod',[]);}
The dollar sign in $jsMethod
should be escaped, otherwise it incorrectly tries to interpolate the rest of the method name.