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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 void removeRange(int start, int end) { | 414 void removeRange(int start, int end) { |
415 _checkRange(start, end, length); | 415 _checkRange(start, end, length); |
416 callMethod('splice', [start, end - start]); | 416 callMethod('splice', [start, end - start]); |
417 } | 417 } |
418 | 418 |
419 void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) { | 419 void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) { |
420 _checkRange(start, end, this.length); | 420 _checkRange(start, end, this.length); |
421 int length = end - start; | 421 int length = end - start; |
422 if (length == 0) return; | 422 if (length == 0) return; |
423 if (skipCount < 0) throw new ArgumentError(skipCount); | 423 if (skipCount < 0) throw new ArgumentError(skipCount); |
424 var args = [start, length]..addAll(iterable.skip(skipCount).take(length)); | 424 var args = <Object>[start, length]..addAll(iterable.skip(skipCount).take(len
gth)); |
425 callMethod('splice', args); | 425 callMethod('splice', args); |
426 } | 426 } |
427 | 427 |
428 void sort([int compare(E a, E b)]) { | 428 void sort([int compare(E a, E b)]) { |
429 // Note: arr.sort(null) is a type error in FF | 429 // Note: arr.sort(null) is a type error in FF |
430 callMethod('sort', compare == null ? [] : [compare]); | 430 callMethod('sort', compare == null ? [] : [compare]); |
431 } | 431 } |
432 } | 432 } |
433 | 433 |
434 bool _isBrowserType(o) => JS('bool', | 434 bool _isBrowserType(o) => JS('bool', |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 ' for (let arg of arguments) {' | 550 ' for (let arg of arguments) {' |
551 ' args.push(arg);' | 551 ' args.push(arg);' |
552 ' }' | 552 ' }' |
553 ' return #(...args);' | 553 ' return #(...args);' |
554 '}', | 554 '}', |
555 f); | 555 f); |
556 _interopCaptureThisExpando[f] = ret; | 556 _interopCaptureThisExpando[f] = ret; |
557 } | 557 } |
558 return ret; | 558 return ret; |
559 } | 559 } |
OLD | NEW |