mirror of
https://github.com/jlengrand/webcomponentsjs.git
synced 2026-03-10 08:51:22 +00:00
install createShadowRoot only if present, fixes #174
This commit is contained in:
@@ -289,13 +289,17 @@ function upgradeDocumentTree(doc) {
|
||||
}
|
||||
|
||||
|
||||
// ensure that all ShadowRoots watch for CustomElements.
|
||||
// Patch `createShadowRoot()` if Shadow DOM is available, otherwise leave
|
||||
// undefined to aid feature detection of Shadow DOM.
|
||||
var originalCreateShadowRoot = Element.prototype.createShadowRoot;
|
||||
Element.prototype.createShadowRoot = function() {
|
||||
var root = originalCreateShadowRoot.call(this);
|
||||
CustomElements.watchShadow(this);
|
||||
return root;
|
||||
};
|
||||
if (originalCreateShadowRoot) {
|
||||
// ensure that all ShadowRoots watch for CustomElements.
|
||||
Element.prototype.createShadowRoot = function() {
|
||||
var root = originalCreateShadowRoot.call(this);
|
||||
CustomElements.watchShadow(this);
|
||||
return root;
|
||||
};
|
||||
}
|
||||
|
||||
// exports
|
||||
scope.watchShadow = watchShadow;
|
||||
|
||||
Reference in New Issue
Block a user