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

Commit

Permalink
Restore compatibility between TemplateBinding and Custom Elements pol…
Browse files Browse the repository at this point in the history
…yfill. TemplateBinding now uses a staging document for creating elements. Elements should be upgraded there.

Custom Elements requires manually setting up documents to support custom elements. To solve this generally, this requirement could be removed. Alternatively, TemplateBinding could be setup to work with the CE polyfill. For simplicity we’ve directly patched importNode here. This is the mechanism TemplateBinding uses to create dom in the staging document. Also included is a temp workaround for SD polyfill support for importNode.
  • Loading branch information
sorvell committed Nov 21, 2013
1 parent 4f727e1 commit bd2f591
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/patches-mdv.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,24 @@ window.addEventListener('WebComponentsReady', function() {
}
});


if (window.CustomElements && !CustomElements.useNative) {
var originalImportNode = Document.prototype.importNode;
Document.prototype.importNode = function(node, deep) {
// TODO(sorvell): remove these conditionals when polyfill supports importNode
// https://github.com/Polymer/ShadowDOM/issues/317
if (window.ShadowDOMPolyfill) {
node = ShadowDOMPolyfill.unwrap(node);
}
var imported = originalImportNode.call(this, node, deep);
CustomElements.upgradeAll(imported);
if (window.ShadowDOMPolyfill) {
imported = ShadowDOMPolyfill.wrap(imported);
}
return imported;
}
}

// exports
scope.flush = flush;

Expand Down

0 comments on commit bd2f591

Please sign in to comment.