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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 args == null ? null : new List.from(args.map(_convertToJS)))); | 310 args == null ? null : new List.from(args.map(_convertToJS)))); |
311 } | 311 } |
312 | 312 |
313 // TODO(jmesserly): this is totally unnecessary in dev_compiler. | 313 // TODO(jmesserly): this is totally unnecessary in dev_compiler. |
314 /** A [List] that proxies a JavaScript array. */ | 314 /** A [List] that proxies a JavaScript array. */ |
315 class JsArray<E> extends JsObject with ListMixin<E> { | 315 class JsArray<E> extends JsObject with ListMixin<E> { |
316 | 316 |
317 /** | 317 /** |
318 * Creates a new JavaScript array. | 318 * Creates a new JavaScript array. |
319 */ | 319 */ |
320 JsArray() : super._fromJs([]); | 320 // TODO(vsm): Making this a factory to workaround #537. |
| 321 factory JsArray() { return new JsArray._fromJs([]); } |
321 | 322 |
322 /** | 323 /** |
323 * Creates a new JavaScript array and initializes it to the contents of | 324 * Creates a new JavaScript array and initializes it to the contents of |
324 * [other]. | 325 * [other]. |
325 */ | 326 */ |
326 JsArray.from(Iterable<E> other) | 327 JsArray.from(Iterable<E> other) |
327 : super._fromJs([]..addAll(other.map(_convertToJS))); | 328 : super._fromJs([]..addAll(other.map(_convertToJS))); |
328 | 329 |
329 JsArray._fromJs(jsObject) : super._fromJs(jsObject); | 330 JsArray._fromJs(jsObject) : super._fromJs(jsObject); |
330 | 331 |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 ' for (let arg of arguments) {' | 551 ' for (let arg of arguments) {' |
551 ' args.push(arg);' | 552 ' args.push(arg);' |
552 ' }' | 553 ' }' |
553 ' return #(...args);' | 554 ' return #(...args);' |
554 '}', | 555 '}', |
555 f); | 556 f); |
556 _interopCaptureThisExpando[f] = ret; | 557 _interopCaptureThisExpando[f] = ret; |
557 } | 558 } |
558 return ret; | 559 return ret; |
559 } | 560 } |
OLD | NEW |