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

Unified Diff: pkg/custom_element/lib/custom-elements.debug.js

Issue 26558008: Adding platform patches to allow custom elements polyfill to work with Shadow DOM. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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 | « no previous file | pkg/custom_element/lib/custom-elements.min.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/custom_element/lib/custom-elements.debug.js
diff --git a/pkg/custom_element/lib/custom-elements.debug.js b/pkg/custom_element/lib/custom-elements.debug.js
index a391b8ac3da3a22a4ad7839ae54c1dd472c6d992..07e93804514da025fc5db252325e12e9436c61c0 100644
--- a/pkg/custom_element/lib/custom-elements.debug.js
+++ b/pkg/custom_element/lib/custom-elements.debug.js
@@ -1436,4 +1436,33 @@ if (HTMLElement.prototype.createShadowRoot) {
return root;
}
}
+
+
+// Patch to allow custom elements and shadow dom to work together, from:
+// https://github.com/Polymer/platform/blob/master/src/patches-custom-elements.js
+if (window.ShadowDOMPolyfill) {
+ function nop() {};
+
+ // disable shadow dom watching
+ CustomElements.watchShadow = nop;
+ CustomElements.watchAllShadows = nop;
+
+ // ensure wrapped inputs for these functions
+ var fns = ['upgradeAll', 'upgradeSubtree', 'observeDocument',
+ 'upgradeDocument'];
+
+ // cache originals
+ var original = {};
+ fns.forEach(function(fn) {
+ original[fn] = CustomElements[fn];
+ });
+
+ // override
+ fns.forEach(function(fn) {
+ CustomElements[fn] = function(inNode) {
+ return original[fn](ShadowDOMPolyfill.wrapIfNeeded(inNode));
+ };
+ });
+}
+
})();
« no previous file with comments | « no previous file | pkg/custom_element/lib/custom-elements.min.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698