Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Stop routing createShadowRoot to webkitCreateShadowRoot; only patch c…
Browse files Browse the repository at this point in the history
…reateShadowRoot in the presence of the CustomElements polyfill.
  • Loading branch information
sorvell committed Mar 14, 2014
1 parent 4b50c5f commit 59f745d
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions src/patches-shadowdom-native.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,18 @@
window.wrap = window.unwrap = function(n){
return n;
}

var originalCreateShadowRoot = Element.prototype.webkitCreateShadowRoot;
Element.prototype.webkitCreateShadowRoot = function() {
var elderRoot = this.webkitShadowRoot;
var root = originalCreateShadowRoot.call(this);
root.olderShadowRoot = elderRoot;
root.host = this;
CustomElements.watchShadow(this);
return root;
}

Object.defineProperties(Element.prototype, {
shadowRoot: {
get: function() {
return this.webkitShadowRoot;
}
},
createShadowRoot: {
value: function() {
return this.webkitCreateShadowRoot();
}

addEventListener('DOMContentLoaded', function() {
if (CustomElements.useNative === false) {
var originalCreateShadowRoot = Element.prototype.createShadowRoot;
Element.prototype.createShadowRoot = function() {
var root = originalCreateShadowRoot.call(this);
CustomElements.watchShadow(this);
return root;
};
}
});

window.templateContent = function(inTemplate) {
// if MDV exists, it may need to boostrap this template to reveal content
if (window.HTMLTemplateElement && HTMLTemplateElement.bootstrap) {
Expand Down

0 comments on commit 59f745d

Please sign in to comment.