Skip to content

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

Closed
@greglittlefield-wf

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    web-js-interopIssues that impact all js interop

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions