Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Unified Diff: third_party/polymer/v0_8/components/polymer/src/lib/dom-module.html

Issue 1082403004: Import Polymer 0.8 and several key elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Also remove polymer/explainer Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/polymer/v0_8/components/polymer/src/lib/dom-module.html
diff --git a/third_party/polymer/v0_8/components/polymer/src/lib/dom-module.html b/third_party/polymer/v0_8/components/polymer/src/lib/dom-module.html
new file mode 100644
index 0000000000000000000000000000000000000000..442dc15f8f4dec030fcc82e61cb7c48f6a0e1dce
--- /dev/null
+++ b/third_party/polymer/v0_8/components/polymer/src/lib/dom-module.html
@@ -0,0 +1,68 @@
+<script>
+
+(function() {
+
+ var modules = {};
+
+ var DomModule = function() {
+ return document.createElement('dom-module');
+ };
+
+ DomModule.prototype = Object.create(HTMLElement.prototype);
+
+ DomModule.prototype.constructor = DomModule;
+
+ DomModule.prototype.createdCallback = function() {
+ var id = this.id || this.getAttribute('name') || this.getAttribute('is');
+ if (id) {
+ this.id = id;
+ modules[id] = this;
+ }
+ };
+
+ DomModule.prototype.import = function(id, slctr) {
+ var m = modules[id];
+ if (!m) {
+ // If polyfilling, a script can run before a dom-module element
+ // is upgraded. We force the containing document to upgrade
+ // and try again to workaround this polyfill limitation.
+ forceDocumentUpgrade();
+ m = modules[id];
+ }
+ if (m && slctr) {
+ m = m.querySelector(slctr);
+ }
+ return m;
+ };
+
+ // NOTE: HTMLImports polyfill does not
+ // block scripts on upgrading elements. However, we want to ensure that
+ // any dom-module in the tree is available prior to a subsequent script
+ // processing.
+ // Therefore, we force any dom-modules in the tree to upgrade when dom-module
+ // is registered by temporarily setting CE polyfill to crawl the entire
+ // imports tree. (Note: this should only upgrade any imports that have been
+ // loaded by this point. In addition the HTMLImports polyfill should be
+ // changed to upgrade elements prior to running any scripts.)
+ var cePolyfill = window.CustomElements && !CustomElements.useNative;
+ if (cePolyfill) {
+ var ready = CustomElements.ready;
+ CustomElements.ready = true;
+ }
+ document.registerElement('dom-module', DomModule);
+ if (cePolyfill) {
+ CustomElements.ready = ready;
+ }
+
+ function forceDocumentUpgrade() {
+ if (cePolyfill) {
+ var script = document._currentScript || document.currentScript;
+ if (script) {
+ CustomElements.upgradeAll(script.ownerDocument);
+ }
+ }
+ }
+
+})();
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698