Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Unified Diff: tools/dom/templates/html/dartium/html_dartium.darttemplate

Issue 1380963003: Preserve identity of Dart wrappers on DOM objects (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« sdk/lib/js/dartium/js_dartium.dart ('K') | « tests/html/js_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/templates/html/dartium/html_dartium.darttemplate
diff --git a/tools/dom/templates/html/dartium/html_dartium.darttemplate b/tools/dom/templates/html/dartium/html_dartium.darttemplate
index b15dab237afe597501927d563a74b151841e4748..7cd522c372404a6faee30022be59761176f70e86 100644
--- a/tools/dom/templates/html/dartium/html_dartium.darttemplate
+++ b/tools/dom/templates/html/dartium/html_dartium.darttemplate
@@ -390,10 +390,19 @@ unwrap_jso(dartClass_instance) {
*/
wrap_jso(jsObject) {
try {
- if (jsObject is! js.JsObject) {
+ if (jsObject is! js.JsObject || jsObject == null) {
// JS Interop converted the object to a Dart class e.g., Uint8ClampedList.
+ // or it's a simple type.
return jsObject;
}
+
+ // TODO(alanknight): With upgraded custom elements this causes a failure because
+ // we need a new wrapper after the type changes. We could possibly invalidate this
+ // if the constructor name didn't match?
+ if (jsObject.dartWrapper != null) {
+ return jsObject.dartWrapper;
+ }
+
// Try the most general type conversions on it.
// TODO(alanknight): We may be able to do better. This maintains identity,
// which is useful, but expensive. And if we nest something that only
@@ -420,6 +429,7 @@ wrap_jso(jsObject) {
if (func != null) {
dartClass_instance = func();
dartClass_instance.blink_jsObject = jsObject;
+ jsObject.dartWrapper = dartClass_instance;
}
}
return dartClass_instance;
« sdk/lib/js/dartium/js_dartium.dart ('K') | « tests/html/js_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698