install createShadowRoot only if present, fixes #174

This commit is contained in:
John Messerly
2015-01-28 08:38:55 -08:00
parent 574768b8cd
commit 56317fb952

View File

@@ -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;