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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 * * `TypedData`, including its subclasses like `Int32List`, but _not_ | 69 * * `TypedData`, including its subclasses like `Int32List`, but _not_ |
70 * `ByteBuffer` | 70 * `ByteBuffer` |
71 * * `Window` | 71 * * `Window` |
72 * | 72 * |
73 * ## Converting collections with JsObject.jsify() | 73 * ## Converting collections with JsObject.jsify() |
74 * | 74 * |
75 * To create a JavaScript collection from a Dart collection use the | 75 * To create a JavaScript collection from a Dart collection use the |
76 * [JsObject.jsify] constructor, which converts Dart [Map]s and [Iterable]s | 76 * [JsObject.jsify] constructor, which converts Dart [Map]s and [Iterable]s |
77 * into JavaScript Objects and Arrays. | 77 * into JavaScript Objects and Arrays. |
78 * | 78 * |
79 * The following expression creats a new JavaScript object with the properties | 79 * The following expression creates a new JavaScript object with the properties |
80 * `a` and `b` defined: | 80 * `a` and `b` defined: |
81 * | 81 * |
82 * var jsMap = new JsObject.jsify({'a': 1, 'b': 2}); | 82 * var jsMap = new JsObject.jsify({'a': 1, 'b': 2}); |
83 * | 83 * |
84 * This expression creates a JavaScript array: | 84 * This expression creates a JavaScript array: |
85 * | 85 * |
86 * var jsArray = new JsObject.jsify([1, 2, 3]); | 86 * var jsArray = new JsObject.jsify([1, 2, 3]); |
87 */ | 87 */ |
88 library dart.js; | 88 library dart.js; |
89 | 89 |
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 Function allowInteropCaptureThis(Function f) { | 719 Function allowInteropCaptureThis(Function f) { |
720 if (JS('bool', 'typeof(#) == "function"', f)) { | 720 if (JS('bool', 'typeof(#) == "function"', f)) { |
721 // Behavior when the function is already a JS function is unspecified. | 721 // Behavior when the function is already a JS function is unspecified. |
722 throw new ArgumentError( | 722 throw new ArgumentError( |
723 "Function is already a JS function so cannot capture this."); | 723 "Function is already a JS function so cannot capture this."); |
724 return f; | 724 return f; |
725 } else { | 725 } else { |
726 return _convertDartFunctionFastCaptureThis(f); | 726 return _convertDartFunctionFastCaptureThis(f); |
727 } | 727 } |
728 } | 728 } |
OLD | NEW |