| Index: pkg/compiler/lib/src/js_backend/native_data.dart
|
| diff --git a/pkg/compiler/lib/src/js_backend/native_data.dart b/pkg/compiler/lib/src/js_backend/native_data.dart
|
| index 67b473b53c5c0badc6dfac4e4a0f9b8ec063bf45..31fe7d69fea1bf11dbf707181e0b4b1361f404e3 100644
|
| --- a/pkg/compiler/lib/src/js_backend/native_data.dart
|
| +++ b/pkg/compiler/lib/src/js_backend/native_data.dart
|
| @@ -35,6 +35,10 @@ class NativeData {
|
| Map<MemberElement, NativeBehavior> nativeFieldStoreBehavior =
|
| <FieldElement, NativeBehavior>{};
|
|
|
| + /// Prefix used to escape JS names that are not valid Dart names
|
| + /// when using JSInterop.
|
| + static const String _jsInteropEscapePrefix = r'JS$';
|
| +
|
| /// Returns `true` if [element] is explicitly marked as part of JsInterop.
|
| bool _isJsInterop(Element element) {
|
| return jsInteropNames.containsKey(element.declaration);
|
| @@ -93,7 +97,7 @@ class NativeData {
|
| if (jsInteropName != null && jsInteropName.isNotEmpty) {
|
| return jsInteropName;
|
| }
|
| - return element.isLibrary ? 'self' : element.name;
|
| + return element.isLibrary ? 'self' : getUnescapedJSInteropName(element.name);
|
| }
|
|
|
| /// Computes the name for [element] to use in the generated JavaScript. This
|
| @@ -216,4 +220,12 @@ class NativeData {
|
| FieldElement field, NativeBehavior behavior) {
|
| nativeFieldStoreBehavior[field] = behavior;
|
| }
|
| +
|
| + /// Apply JS$ escaping scheme to convert possible escaped Dart names into
|
| + /// JS names.
|
| + String getUnescapedJSInteropName(String name) {
|
| + return name.startsWith(_jsInteropEscapePrefix)
|
| + ? name.substring(_jsInteropEscapePrefix.length)
|
| + : name;
|
| + }
|
| }
|
|
|