| 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 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) { | 448 void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) { |
| 449 _checkRange(start, end, length); | 449 _checkRange(start, end, length); |
| 450 int length = end - start; | 450 int length = end - start; |
| 451 if (length == 0) return; | 451 if (length == 0) return; |
| 452 if (skipCount < 0) throw new ArgumentError(skipCount); | 452 if (skipCount < 0) throw new ArgumentError(skipCount); |
| 453 var args = [start, length]..addAll(iterable.skip(skipCount).take(length)); | 453 var args = [start, length]..addAll(iterable.skip(skipCount).take(length)); |
| 454 callMethod('splice', args); | 454 callMethod('splice', args); |
| 455 } | 455 } |
| 456 | 456 |
| 457 void sort([int compare(E a, E b)]) { | 457 void sort([int compare(E a, E b)]) { |
| 458 callMethod('sort', [compare]); | 458 // Note: arr.sort(null) is a type error in FF |
| 459 callMethod('sort', compare == null ? [] : [compare]); |
| 459 } | 460 } |
| 460 } | 461 } |
| 461 | 462 |
| 462 // property added to a Dart object referencing its JS-side DartObject proxy | 463 // property added to a Dart object referencing its JS-side DartObject proxy |
| 463 final String _DART_OBJECT_PROPERTY_NAME = | 464 final String _DART_OBJECT_PROPERTY_NAME = |
| 464 getIsolateAffinityTag(r'_$dart_dartObject'); | 465 getIsolateAffinityTag(r'_$dart_dartObject'); |
| 465 final String _DART_CLOSURE_PROPERTY_NAME = | 466 final String _DART_CLOSURE_PROPERTY_NAME = |
| 466 getIsolateAffinityTag(r'_$dart_dartClosure'); | 467 getIsolateAffinityTag(r'_$dart_dartClosure'); |
| 467 | 468 |
| 468 // property added to a JS object referencing its Dart-side JsObject proxy | 469 // property added to a JS object referencing its Dart-side JsObject proxy |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 // Dart in that context. The JS object will have a cached proxy | 575 // Dart in that context. The JS object will have a cached proxy |
| 575 // but it won't be a valid Dart object in this context. | 576 // but it won't be a valid Dart object in this context. |
| 576 // For now we throw away the cached proxy, but we should be able | 577 // For now we throw away the cached proxy, but we should be able |
| 577 // to cache proxies from multiple JS contexts and Dart isolates. | 578 // to cache proxies from multiple JS contexts and Dart isolates. |
| 578 if (dartProxy == null || !_isLocalObject(o)) { | 579 if (dartProxy == null || !_isLocalObject(o)) { |
| 579 dartProxy = createProxy(o); | 580 dartProxy = createProxy(o); |
| 580 _defineProperty(o, propertyName, dartProxy); | 581 _defineProperty(o, propertyName, dartProxy); |
| 581 } | 582 } |
| 582 return dartProxy; | 583 return dartProxy; |
| 583 } | 584 } |
| OLD | NEW |