| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 25 matching lines...) Expand all Loading... |
| 36 * import 'dart:js'; | 36 * import 'dart:js'; |
| 37 * | 37 * |
| 38 * main() { | 38 * main() { |
| 39 * var object = new JsObject(context['Object']); | 39 * var object = new JsObject(context['Object']); |
| 40 * object['greeting'] = 'Hello'; | 40 * object['greeting'] = 'Hello'; |
| 41 * object['greet'] = (name) => "${object['greeting']} $name"; | 41 * object['greet'] = (name) => "${object['greeting']} $name"; |
| 42 * var message = object.callMethod('greet', ['JavaScript']); | 42 * var message = object.callMethod('greet', ['JavaScript']); |
| 43 * context['console'].callMethod('log', [message]); | 43 * context['console'].callMethod('log', [message]); |
| 44 * } | 44 * } |
| 45 * | 45 * |
| 46 * ## Proxying and Automatic Conversion | 46 * ## Proxying and automatic conversion |
| 47 * | 47 * |
| 48 * When setting properties on a JsObject or passing arguments to a Javascript | 48 * When setting properties on a JsObject or passing arguments to a Javascript |
| 49 * method or function, Dart objects are automatically converted or proxied to | 49 * method or function, Dart objects are automatically converted or proxied to |
| 50 * JavaScript objects. When accessing JavaScript properties, or when a Dart | 50 * JavaScript objects. When accessing JavaScript properties, or when a Dart |
| 51 * closure is invoked from JavaScript, the JavaScript objects are also | 51 * closure is invoked from JavaScript, the JavaScript objects are also |
| 52 * converted to Dart. | 52 * converted to Dart. |
| 53 * | 53 * |
| 54 * Functions and closures are proxied in such a way that they are callable. A | 54 * Functions and closures are proxied in such a way that they are callable. A |
| 55 * Dart closure assigned to a JavaScript property is proxied by a function in | 55 * Dart closure assigned to a JavaScript property is proxied by a function in |
| 56 * JavaScript. A JavaScript function accessed from Dart is proxied by a | 56 * JavaScript. A JavaScript function accessed from Dart is proxied by a |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 /** | 369 /** |
| 370 * Returns a method that can be called with an arbitrary number (for n less | 370 * Returns a method that can be called with an arbitrary number (for n less |
| 371 * than 11) of arguments without violating Dart type checks. | 371 * than 11) of arguments without violating Dart type checks. |
| 372 */ | 372 */ |
| 373 Function _wrapAsDebuggerVarArgsFunction(JsFunction jsFunction) => | 373 Function _wrapAsDebuggerVarArgsFunction(JsFunction jsFunction) => |
| 374 ([a1=_UNDEFINED, a2=_UNDEFINED, a3=_UNDEFINED, a4=_UNDEFINED, | 374 ([a1=_UNDEFINED, a2=_UNDEFINED, a3=_UNDEFINED, a4=_UNDEFINED, |
| 375 a5=_UNDEFINED, a6=_UNDEFINED, a7=_UNDEFINED, a8=_UNDEFINED, | 375 a5=_UNDEFINED, a6=_UNDEFINED, a7=_UNDEFINED, a8=_UNDEFINED, |
| 376 a9=_UNDEFINED, a10=_UNDEFINED]) => | 376 a9=_UNDEFINED, a10=_UNDEFINED]) => |
| 377 jsFunction._applyDebuggerOnly(_stripUndefinedArgs( | 377 jsFunction._applyDebuggerOnly(_stripUndefinedArgs( |
| 378 [a1,a2,a3,a4,a5,a6,a7,a8,a9,a10])); | 378 [a1,a2,a3,a4,a5,a6,a7,a8,a9,a10])); |
| OLD | NEW |