Chromium Code Reviews| Index: sdk/lib/js/dart2js/js_dart2js.dart |
| diff --git a/sdk/lib/js/dart2js/js_dart2js.dart b/sdk/lib/js/dart2js/js_dart2js.dart |
| index 576cb23451a596c23f569eecca11f7185d2cebbb..61131d5418bf669394dcbd02b43187f852482850 100644 |
| --- a/sdk/lib/js/dart2js/js_dart2js.dart |
| +++ b/sdk/lib/js/dart2js/js_dart2js.dart |
| @@ -4,7 +4,7 @@ |
| /** |
| * Support for interoperating with JavaScript. |
| - * |
| + * |
| * This library provides access to JavaScript objects from Dart, allowing |
| * Dart code to get and set properties, and call methods of JavaScript objects |
| * and invoke JavaScript functions. The library takes care of converting |
| @@ -27,14 +27,14 @@ |
| * global function `alert()`: |
| * |
| * import 'dart:js'; |
| - * |
| + * |
| * main() => context.callMethod('alert', ['Hello from Dart!']); |
| * |
| * This example shows how to create a [JsObject] from a JavaScript constructor |
| * and access its properties: |
| * |
| * import 'dart:js'; |
| - * |
| + * |
| * main() { |
| * var object = new JsObject(context['Object']); |
| * object['greeting'] = 'Hello'; |
| @@ -44,7 +44,7 @@ |
| * } |
| * |
| * ## Proxying and automatic conversion |
| - * |
| + * |
| * When setting properties on a JsObject or passing arguments to a Javascript |
| * method or function, Dart objects are automatically converted or proxied to |
| * JavaScript objects. When accessing JavaScript properties, or when a Dart |
| @@ -80,7 +80,7 @@ |
| * `a` and `b` defined: |
| * |
| * var jsMap = new JsObject.jsify({'a': 1, 'b': 2}); |
| - * |
| + * |
| * This expression creates a JavaScript array: |
| * |
| * var jsArray = new JsObject.jsify([1, 2, 3]); |
| @@ -165,7 +165,7 @@ class JsObject { |
| * Use this constructor only if you wish to get access to JavaScript |
| * properties attached to a browser host object, such as a Node or Blob, that |
| * is normally automatically converted into a native Dart object. |
| - * |
| + * |
| * An exception will be thrown if [object] either is `null` or has the type |
| * `bool`, `num`, or `String`. |
| */ |
| @@ -232,7 +232,7 @@ class JsObject { |
| } |
| return _convertToDart(JS('', '#[#]', _jsObject, property)); |
| } |
| - |
| + |
| /** |
| * Sets the value associated with [property] on the proxied JavaScript |
| * object. |
| @@ -410,7 +410,7 @@ class JsArray<E> extends JsObject with ListMixin<E> { |
| } |
| void addAll(Iterable<E> iterable) { |
| - var list = (JS('bool', '# instanceof Array', iterable)) |
| + var list = (JS('bool', '# instanceof Array', iterable)) |
| ? iterable |
| : new List.from(iterable); |
| callMethod('push', list); |
| @@ -451,8 +451,8 @@ class JsArray<E> extends JsObject with ListMixin<E> { |
| } |
| // property added to a Dart object referencing its JS-side DartObject proxy |
| -const _DART_OBJECT_PROPERTY_NAME = r'_$dart_dartObject'; |
| -const _DART_CLOSURE_PROPERTY_NAME = r'_$dart_dartClosure'; |
| +var _DART_OBJECT_PROPERTY_NAME = ""; |
| +var _DART_CLOSURE_PROPERTY_NAME = ""; |
| // property added to a JS object referencing its Dart-side JsObject proxy |
| const _JS_OBJECT_PROPERTY_NAME = r'_$dart_jsObject'; |
| @@ -537,6 +537,12 @@ Object _convertToDart(o) { |
| } |
| JsObject _wrapToDart(o) { |
| + if (_DART_OBJECT_PROPERTY_NAME == "") { |
| + int counter = JS("int", 'Object["_DART_INTEROP_COUNTER_"]||0'); |
|
sra1
2014/02/13 04:27:26
Pull _DART_INTEROP_COUNTER out into variable that
floitsch
2014/02/13 16:26:57
Done.
|
| + JS("", 'Object["_DART_INTEROP_COUNTER_"]=#', counter + 1); |
| + _DART_OBJECT_PROPERTY_NAME = "_\$dart_dartObject$counter"; |
| + _DART_CLOSURE_PROPERTY_NAME = "_\$dart_dartClosure$counter"; |
|
sra1
2014/02/13 04:27:26
These strings should be interned (possibly as a se
floitsch
2014/02/13 16:26:57
Done.
|
| + } |
| if (JS('bool', 'typeof # == "function"', o)) { |
| return _getDartProxy(o, _DART_CLOSURE_PROPERTY_NAME, |
| (o) => new JsFunction._fromJs(o)); |