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 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 callMethod('splice', args); | 433 callMethod('splice', args); |
434 } | 434 } |
435 | 435 |
436 void sort([int compare(E a, E b)]) { | 436 void sort([int compare(E a, E b)]) { |
437 // Note: arr.sort(null) is a type error in FF | 437 // Note: arr.sort(null) is a type error in FF |
438 callMethod('sort', compare == null ? [] : [compare]); | 438 callMethod('sort', compare == null ? [] : [compare]); |
439 } | 439 } |
440 } | 440 } |
441 | 441 |
442 // Cross frame objects should not be considered browser types. | 442 // Cross frame objects should not be considered browser types. |
443 // We include the the instanceof Object test to filter out cross frame objects | 443 // We include the instanceof Object test to filter out cross frame objects |
444 // on FireFox. Surprisingly on FireFox the instanceof Window test succeeds for | 444 // on FireFox. Surprisingly on FireFox the instanceof Window test succeeds for |
445 // cross frame windows while the instanceof Object test fails. | 445 // cross frame windows while the instanceof Object test fails. |
446 bool _isBrowserType(o) => JS( | 446 bool _isBrowserType(o) => JS( |
447 'bool', | 447 'bool', |
448 '# instanceof Object && (' | 448 '# instanceof Object && (' |
449 '# instanceof Blob || ' | 449 '# instanceof Blob || ' |
450 '# instanceof Event || ' | 450 '# instanceof Event || ' |
451 '(window.KeyRange && # instanceof KeyRange) || ' | 451 '(window.KeyRange && # instanceof KeyRange) || ' |
452 '(window.IDBKeyRange && # instanceof IDBKeyRange) || ' | 452 '(window.IDBKeyRange && # instanceof IDBKeyRange) || ' |
453 '# instanceof ImageData || ' | 453 '# instanceof ImageData || ' |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 ' for (let arg of arguments) {' | 580 ' for (let arg of arguments) {' |
581 ' args.push(arg);' | 581 ' args.push(arg);' |
582 ' }' | 582 ' }' |
583 ' return #(...args);' | 583 ' return #(...args);' |
584 '}', | 584 '}', |
585 f); | 585 f); |
586 _interopCaptureThisExpando[f] = ret; | 586 _interopCaptureThisExpando[f] = ret; |
587 } | 587 } |
588 return ret; | 588 return ret; |
589 } | 589 } |
OLD | NEW |