Skip to content

Dartium JS interop patch doesn't escape dollar signs in identifiers #26718

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
greglittlefield-wf opened this issue Jun 16, 2016 · 1 comment
Closed
Labels
web-js-interop Issues that impact all js interop

Comments

@greglittlefield-wf
Copy link
Contributor

@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.

@jacob314
Copy link
Member

Full fix provided by 96ca5db

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