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 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 return _getDartProxy(o, _DART_OBJECT_PROPERTY_NAME, | 537 return _getDartProxy(o, _DART_OBJECT_PROPERTY_NAME, |
538 (o) => new JsArray._fromJs(o)); | 538 (o) => new JsArray._fromJs(o)); |
539 } else { | 539 } else { |
540 return _getDartProxy(o, _DART_OBJECT_PROPERTY_NAME, | 540 return _getDartProxy(o, _DART_OBJECT_PROPERTY_NAME, |
541 (o) => new JsObject._fromJs(o)); | 541 (o) => new JsObject._fromJs(o)); |
542 } | 542 } |
543 } | 543 } |
544 | 544 |
545 Object _getDartProxy(o, String propertyName, createProxy(o)) { | 545 Object _getDartProxy(o, String propertyName, createProxy(o)) { |
546 var dartProxy = JS('', '#[#]', o, propertyName); | 546 var dartProxy = JS('', '#[#]', o, propertyName); |
547 if (dartProxy == null) { | 547 // Temporary fix for dartbug.com/15193 |
| 548 // In some cases it's possible to see a JavaScript object that |
| 549 // came from a different context and was previously proxied to |
| 550 // Dart in that context. The JS object will have a cached proxy |
| 551 // but it won't be a valid Dart object in this context. |
| 552 // For now we throw away the cached proxy, but we should be able |
| 553 // to cache proxies from multiple JS contexts and Dart isolates. |
| 554 if (dartProxy == null || !_isLocalObject(o)) { |
548 dartProxy = createProxy(o); | 555 dartProxy = createProxy(o); |
549 _defineProperty(o, propertyName, dartProxy); | 556 _defineProperty(o, propertyName, dartProxy); |
550 } | 557 } |
551 return dartProxy; | 558 return dartProxy; |
552 } | 559 } |
OLD | NEW |