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

Commit

Permalink
ensure shadowRoots have .host and .olderShadowRoot references; automa…
Browse files Browse the repository at this point in the history
…tically watch native shadowRoots for CustomElements.
  • Loading branch information
sorvell committed Jul 23, 2013
1 parent 5c8d0e8 commit 160cf93
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/patches-shadowdom-native.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@
window.wrap = window.unwrap = function(n){
return n;
}

var originalCreateShadowRoot = HTMLElement.prototype.webkitCreateShadowRoot;
HTMLElement.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(HTMLElement.prototype, {
shadowRoot: {
Expand Down
8 changes: 8 additions & 0 deletions src/patches-shadowdom-polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@
}
}
});

// include .host reference
var originalCreateShadowRoot = HTMLElement.prototype.createShadowRoot;
HTMLElement.prototype.createShadowRoot = function() {
var root = originalCreateShadowRoot.call(this);
root.host = this;
return root;
}

//TODO(sjmiles): review method alias with Arv
HTMLElement.prototype.webkitCreateShadowRoot =
Expand Down

0 comments on commit 160cf93

Please sign in to comment.