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

Unified Diff: sdk/lib/_internal/lib/native_helper.dart

Issue 86993002: Assume Document may be HtmlDocument (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/lib/native_helper.dart
diff --git a/sdk/lib/_internal/lib/native_helper.dart b/sdk/lib/_internal/lib/native_helper.dart
index 65008e41cf86e95e1541514d26e826a86219a9e9..4362a8e889c3a35f5c8d8d1bd445f6cb095d430c 100644
--- a/sdk/lib/_internal/lib/native_helper.dart
+++ b/sdk/lib/_internal/lib/native_helper.dart
@@ -389,6 +389,8 @@ void initHooks() {
hooks = applyHooksTransformer(_operaHooksTransformer, hooks);
hooks = applyHooksTransformer(_safariHooksTransformer, hooks);
+ hooks = applyHooksTransformer(_fixDocumentHooksTransformer, hooks);
+
// TODO(sra): Update ShadowDOM polyfil to use
// [dartNativeDispatchHooksTransformer] and remove this hook.
hooks = applyHooksTransformer(_dartExperimentalFixupGetTagHooksTransformer,
@@ -546,14 +548,6 @@ function(hooks) {
var tag = getTag(o);
var newTag = quickMap[tag];
if (newTag) return newTag;
- if (tag == "Document") {
- // IE calls both HTML and XML documents "Document", so we check for the
- // xmlVersion property, which is the empty string on HTML documents.
- // Since both dart:html classes Document and HtmlDocument share the same
- // type, we must patch the instances and not the prototype.
- if (!!o.xmlVersion) return "!Document";
- return "!HTMLDocument";
- }
// Patches for types which report themselves as Objects.
if (tag == "Object") {
if (window.DataView && (o instanceof window.DataView)) return "DataView";
@@ -562,7 +556,6 @@ function(hooks) {
}
function prototypeForTagIE(tag) {
- if (tag == "Document") return null; // Do not pre-patch Document.
var constructor = window[tag];
if (constructor == null) return null;
return constructor.prototype;
@@ -572,6 +565,32 @@ function(hooks) {
hooks.prototypeForTag = prototypeForTagIE;
}''');
+const _fixDocumentHooksTransformer = const JS_CONST(r'''
+function(hooks) {
+ var getTag = hooks.getTag;
+ var prototypeForTag = hooks.prototypeForTag;
+ function getTagFixed(o) {
+ var tag = getTag(o);
+ if (tag == "Document") {
+ // Some browsers and the polymer polyfill call both HTML and XML documents
+ // "Document", so we check for the xmlVersion property, which is the empty
+ // string on HTML documents. Since both dart:html classes Document and
+ // HtmlDocument share the same type, we must patch the instances and not
+ // the prototype.
+ if (!!o.xmlVersion) return "!Document";
+ return "!HTMLDocument";
+ }
+ return tag;
+ }
+
+ function prototypeForTagFixed(tag) {
+ if (tag == "Document") return null; // Do not pre-patch Document.
+ return prototypeForTag(tag);
+ }
+
+ hooks.getTag = getTagFixed;
+ hooks.prototypeForTag = prototypeForTagFixed;
+}''');
const _firefoxHooksTransformer = const JS_CONST(r'''
function(hooks) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698