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

Unified Diff: pkg/dev_compiler/tool/input_sdk/private/js_helper.dart

Issue 2952363003: Handle toString on DOM types (Closed)
Patch Set: Created 3 years, 6 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
Index: pkg/dev_compiler/tool/input_sdk/private/js_helper.dart
diff --git a/pkg/dev_compiler/tool/input_sdk/private/js_helper.dart b/pkg/dev_compiler/tool/input_sdk/private/js_helper.dart
index 578c724728d0b83303532825c4b0036e5e0f5096..44bc081819599f373896e3a5cd9267e070bb248e 100644
--- a/pkg/dev_compiler/tool/input_sdk/private/js_helper.dart
+++ b/pkg/dev_compiler/tool/input_sdk/private/js_helper.dart
@@ -192,9 +192,17 @@ class Primitives {
/// In minified mode, uses the unminified names if available.
Jennifer Messerly 2017/06/23 18:27:11 this one too
vsm 2017/06/26 20:29:24 deleted
static String objectToString(Object object) {
- // String name = objectTypeName(object);
- String name = JS('String', 'dart.typeName(dart.getReifiedType(#))', object);
- return "Instance of '$name'";
+ bool nativeType = JS('bool', 'typeof # == "object" && !(# instanceof #)',
Jennifer Messerly 2017/06/23 18:27:11 the normal way to check this is `getExtensionType`
vsm 2017/06/26 20:29:24 Ahh, all our extension types (i think) extend Inte
+ object, object, Object);
+ if (nativeType) {
Jennifer Messerly 2017/06/23 18:27:11 very minor suggestion: if you put the conditional
vsm 2017/06/26 20:29:24 We already inferred nativeType as non-nullable. W
+ // Forward DOM types and other JS objects to their native toString method.
+ return JS('String', '#.toString()', object);
+ } else {
+ // Otherwise, fall back on default Object implemation.
+ String name =
+ JS('String', 'dart.typeName(dart.getReifiedType(#))', object);
Jennifer Messerly 2017/06/23 18:27:11 can this just call `typeName(getReifiedType(object
vsm 2017/06/26 20:29:24 I was going to say we have no way to import our ru
+ return "Instance of '$name'";
+ }
}
static int dateNow() => JS('int', r'Date.now()');

Powered by Google App Engine
This is Rietveld 408576698