Index: sdk/lib/_internal/js_runtime/lib/native_helper.dart |
diff --git a/sdk/lib/_internal/js_runtime/lib/native_helper.dart b/sdk/lib/_internal/js_runtime/lib/native_helper.dart |
index c6aad9430c4302c697a8244b7b667d39de0029fd..30d3ba7458745ee64f0a0888b47e10f3c32f51ff 100644 |
--- a/sdk/lib/_internal/js_runtime/lib/native_helper.dart |
+++ b/sdk/lib/_internal/js_runtime/lib/native_helper.dart |
@@ -449,9 +449,13 @@ applyHooksTransformer(transformer, hooks) { |
const _baseHooks = const JS_CONST(r''' |
function() { |
- var toStringFunction = Object.prototype.toString; |
- function getTag(o) { |
- var s = toStringFunction.call(o); |
+ function typeNameInChrome(o) { |
+ var constructor = o.constructor; |
+ if (constructor) { |
+ var name = constructor.name; |
+ if (name) return name; |
+ } |
+ var s = Object.prototype.toString.call(o); |
return s.substring(8, s.length - 1); |
} |
function getUnknownTag(object, tag) { |
@@ -459,7 +463,7 @@ function() { |
// here allows [getUnknownTag] to be tested on d8. |
if (/^HTML[A-Z].*Element$/.test(tag)) { |
// Check that it is not a simple JavaScript object. |
- var name = toStringFunction.call(object); |
+ var name = Object.prototype.toString.call(object); |
if (name == "[object Object]") return null; |
return "HTMLElement"; |
} |
@@ -480,7 +484,7 @@ function() { |
var isBrowser = typeof navigator == "object"; |
return { |
- getTag: getTag, |
+ getTag: typeNameInChrome, |
getUnknownTag: isBrowser ? getUnknownTagGenericBrowser : getUnknownTag, |
prototypeForTag: prototypeForTag, |
discriminator: discriminator }; |