| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Support for interoperating with JavaScript. | 6 * Support for interoperating with JavaScript. |
| 7 * | 7 * |
| 8 * This library provides access to JavaScript objects from Dart, allowing | 8 * This library provides access to JavaScript objects from Dart, allowing |
| 9 * Dart code to get and set properties, and call methods of JavaScript objects | 9 * Dart code to get and set properties, and call methods of JavaScript objects |
| 10 * and invoke JavaScript functions. The library takes care of converting | 10 * and invoke JavaScript functions. The library takes care of converting |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 113 |
| 114 /** | 114 /** |
| 115 * Constructs a new JavaScript object from [constructor] and returns a proxy | 115 * Constructs a new JavaScript object from [constructor] and returns a proxy |
| 116 * to it. | 116 * to it. |
| 117 */ | 117 */ |
| 118 factory JsObject(JsFunction constructor, [List arguments]) { | 118 factory JsObject(JsFunction constructor, [List arguments]) { |
| 119 var ctor = constructor._jsObject; | 119 var ctor = constructor._jsObject; |
| 120 if (arguments == null) { | 120 if (arguments == null) { |
| 121 return _wrapToDart(JS('', 'new #()', ctor)); | 121 return _wrapToDart(JS('', 'new #()', ctor)); |
| 122 } | 122 } |
| 123 return _wrapToDart(JS('', 'new #(...#)', ctor, arguments)); | 123 var unwrapped = new List.from(arguments.map(_convertToJS)); |
| 124 return _wrapToDart(JS('', 'new #(...#)', ctor, unwrapped)); |
| 124 } | 125 } |
| 125 | 126 |
| 126 /** | 127 /** |
| 127 * Constructs a [JsObject] that proxies a native Dart object; _for expert use | 128 * Constructs a [JsObject] that proxies a native Dart object; _for expert use |
| 128 * only_. | 129 * only_. |
| 129 * | 130 * |
| 130 * Use this constructor only if you wish to get access to JavaScript | 131 * Use this constructor only if you wish to get access to JavaScript |
| 131 * properties attached to a browser host object, such as a Node or Blob, that | 132 * properties attached to a browser host object, such as a Node or Blob, that |
| 132 * is normally automatically converted into a native Dart object. | 133 * is normally automatically converted into a native Dart object. |
| 133 * | 134 * |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 ' for (let arg of arguments) {' | 550 ' for (let arg of arguments) {' |
| 550 ' args.push(arg);' | 551 ' args.push(arg);' |
| 551 ' }' | 552 ' }' |
| 552 ' return #(...args);' | 553 ' return #(...args);' |
| 553 '}', | 554 '}', |
| 554 f); | 555 f); |
| 555 _interopCaptureThisExpando[f] = ret; | 556 _interopCaptureThisExpando[f] = ret; |
| 556 } | 557 } |
| 557 return ret; | 558 return ret; |
| 558 } | 559 } |
| OLD | NEW |