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

Unified Diff: pkg/web_components/lib/dart_support.js

Issue 329723002: Identify the name of the prototype extended by out-of-app custom elements (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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
« no previous file with comments | « pkg/pkg.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/web_components/lib/dart_support.js
diff --git a/pkg/web_components/lib/dart_support.js b/pkg/web_components/lib/dart_support.js
index 4e1995a4e2840564771c22dee5d0c37f25019821..77948eb29438f24008c56db0078bc50a54249610 100644
--- a/pkg/web_components/lib/dart_support.js
+++ b/pkg/web_components/lib/dart_support.js
@@ -116,6 +116,33 @@
upgraders[name] = upgrader;
}
+
+ // Native custom elements outside the app in Chrome have constructor
+ // names like "x-tag", which need to be translated to the DOM
+ // element they extend. When using the shadow dom polyfill this is
+ // take care of above.
Siggi Cherem (dart-lang) 2014/06/11 19:56:03 nit: take => taken
+ var ShadowDOMPolyfill = window.ShadowDOMPolyfill;
+ if (!ShadowDOMPolyfill) {
+ // dartNativeDispatchHooksTransformer is described on initHooks() in
+ // sdk/lib/_internal/lib/native_helper.dart.
+ if (typeof window.dartNativeDispatchHooksTransformer == 'undefined')
+ window.dartNativeDispatchHooksTransformer = [];
+
+ window.dartNativeDispatchHooksTransformer.push(function(hooks) {
+ var originalGetUnknownTag = hooks.getUnknownTag;
+ hooks.getUnknownTag = function(o, tag) {
+ if (/-/.test(tag)) { // "x-tag"
+ var s = Object.prototype.toString.call(o);
+ var match = s.match(/^\[object ([A-Za-z]*Element)\]$/);
+ if (match) {
+ return match[1];
+ }
+ return originalGetUnknownTag(o, tag);
+ }
+ };
+ });
+ }
+
doc._registerDartTypeUpgrader = registerDartTypeUpgrader;
doc.registerElement = registerElement;
})(document);
« no previous file with comments | « pkg/pkg.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698