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 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 if (JS('bool', '# == null', o) || | 481 if (JS('bool', '# == null', o) || |
482 JS('bool', 'typeof # == "string"', o) || | 482 JS('bool', 'typeof # == "string"', o) || |
483 JS('bool', 'typeof # == "number"', o) || | 483 JS('bool', 'typeof # == "number"', o) || |
484 JS('bool', 'typeof # == "boolean"', o) || | 484 JS('bool', 'typeof # == "boolean"', o) || |
485 _isBrowserType(o)) { | 485 _isBrowserType(o)) { |
486 return o; | 486 return o; |
487 } else if (JS('bool', '# instanceof Date', o)) { | 487 } else if (JS('bool', '# instanceof Date', o)) { |
488 var ms = JS('num', '#.getTime()', o); | 488 var ms = JS('num', '#.getTime()', o); |
489 return new DateTime.fromMillisecondsSinceEpoch(ms); | 489 return new DateTime.fromMillisecondsSinceEpoch(ms); |
490 } else if (o is _DartObject && | 490 } else if (o is _DartObject && |
491 JS('bool', 'dart.jsobject != dart.realRuntimeType(#)', o)) { | 491 JS('bool', 'dart.jsobject != dart.getReifiedType(#)', o)) { |
492 return o._dartObj; | 492 return o._dartObj; |
493 } else { | 493 } else { |
494 return _putIfAbsent(_dartProxies, o, _wrapToDart); | 494 return _putIfAbsent(_dartProxies, o, _wrapToDart); |
495 } | 495 } |
496 } | 496 } |
497 | 497 |
498 JsObject _wrapToDart(o) { | 498 JsObject _wrapToDart(o) { |
499 if (JS('bool', 'typeof # == "function"', o)) { | 499 if (JS('bool', 'typeof # == "function"', o)) { |
500 return new JsFunction._fromJs(o); | 500 return new JsFunction._fromJs(o); |
501 } | 501 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 ' for (let arg of arguments) {' | 551 ' for (let arg of arguments) {' |
552 ' args.push(arg);' | 552 ' args.push(arg);' |
553 ' }' | 553 ' }' |
554 ' return #(...args);' | 554 ' return #(...args);' |
555 '}', | 555 '}', |
556 f); | 556 f); |
557 _interopCaptureThisExpando[f] = ret; | 557 _interopCaptureThisExpando[f] = ret; |
558 } | 558 } |
559 return ret; | 559 return ret; |
560 } | 560 } |
OLD | NEW |