| 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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 bool get _finalized native "Js_interfacesFinalized_Callback"; | 473 bool get _finalized native "Js_interfacesFinalized_Callback"; |
| 474 | 474 |
| 475 JsObject get context { | 475 JsObject get context { |
| 476 if (_cachedContext == null) { | 476 if (_cachedContext == null) { |
| 477 _cachedContext = _context; | 477 _cachedContext = _context; |
| 478 } | 478 } |
| 479 return _cachedContext; | 479 return _cachedContext; |
| 480 } | 480 } |
| 481 | 481 |
| 482 /** | 482 /** |
| 483 * Get the dart wrapper object for object. Top-level so we |
| 484 * we can access it from other libraries without it being |
| 485 * a public instance field on JsObject. |
| 486 */ |
| 487 getDartHtmlWrapperFor(JsObject object) => object._dartHtmlWrapper; |
| 488 |
| 489 /** |
| 490 * Set the dart wrapper object for object. Top-level so we |
| 491 * we can access it from other libraries without it being |
| 492 * a public instance field on JsObject. |
| 493 */ |
| 494 void setDartHtmlWrapperFor(JsObject object, wrapper) { |
| 495 object._dartHtmlWrapper = wrapper; |
| 496 } |
| 497 |
| 498 /** |
| 483 * Proxies a JavaScript object to Dart. | 499 * Proxies a JavaScript object to Dart. |
| 484 * | 500 * |
| 485 * The properties of the JavaScript object are accessible via the `[]` and | 501 * The properties of the JavaScript object are accessible via the `[]` and |
| 486 * `[]=` operators. Methods are callable via [callMethod]. | 502 * `[]=` operators. Methods are callable via [callMethod]. |
| 487 */ | 503 */ |
| 488 class JsObject extends NativeFieldWrapperClass2 { | 504 class JsObject extends NativeFieldWrapperClass2 { |
| 489 JsObject.internal(); | 505 JsObject.internal(); |
| 490 | 506 |
| 491 /** | 507 /** |
| 492 * If this JsObject is wrapped, e.g. DOM objects, then we can save the | 508 * If this JsObject is wrapped, e.g. DOM objects, then we can save the |
| 493 * wrapper here and preserve its identity. | 509 * wrapper here and preserve its identity. |
| 494 */ | 510 */ |
| 495 var dartWrapper; | 511 var _dartHtmlWrapper; |
| 496 | 512 |
| 497 /** | 513 /** |
| 498 * Constructs a new JavaScript object from [constructor] and returns a proxy | 514 * Constructs a new JavaScript object from [constructor] and returns a proxy |
| 499 * to it. | 515 * to it. |
| 500 */ | 516 */ |
| 501 factory JsObject(JsFunction constructor, [List arguments]) { | 517 factory JsObject(JsFunction constructor, [List arguments]) { |
| 502 try { | 518 try { |
| 503 return _create(constructor, arguments); | 519 return _create(constructor, arguments); |
| 504 } catch (e) { | 520 } catch (e) { |
| 505 // Re-throw any errors (returned as a string) as a DomException. | 521 // Re-throw any errors (returned as a string) as a DomException. |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 | 885 |
| 870 /** | 886 /** |
| 871 * Returns a method that can be called with an arbitrary number (for n less | 887 * Returns a method that can be called with an arbitrary number (for n less |
| 872 * than 11) of arguments without violating Dart type checks. | 888 * than 11) of arguments without violating Dart type checks. |
| 873 */ | 889 */ |
| 874 Function _wrapAsDebuggerVarArgsFunction(JsFunction jsFunction) => | 890 Function _wrapAsDebuggerVarArgsFunction(JsFunction jsFunction) => |
| 875 ([a1 = _UNDEFINED, a2 = _UNDEFINED, a3 = _UNDEFINED, a4 = _UNDEFINED, | 891 ([a1 = _UNDEFINED, a2 = _UNDEFINED, a3 = _UNDEFINED, a4 = _UNDEFINED, |
| 876 a5 = _UNDEFINED, a6 = _UNDEFINED, a7 = _UNDEFINED, a8 = _UNDEFINED, | 892 a5 = _UNDEFINED, a6 = _UNDEFINED, a7 = _UNDEFINED, a8 = _UNDEFINED, |
| 877 a9 = _UNDEFINED, a10 = _UNDEFINED]) => jsFunction._applyDebuggerOnly( | 893 a9 = _UNDEFINED, a10 = _UNDEFINED]) => jsFunction._applyDebuggerOnly( |
| 878 _stripUndefinedArgs([a1, a2, a3, a4, a5, a6, a7, a8, a9, a10])); | 894 _stripUndefinedArgs([a1, a2, a3, a4, a5, a6, a7, a8, a9, a10])); |
| OLD | NEW |