From 38ce9b4223bfb5afaa387ca62c5d64bbaf03c2e6 Mon Sep 17 00:00:00 2001 From: Steve Orvell Date: Wed, 14 Aug 2013 11:44:43 -0700 Subject: [PATCH] noscript should now work better when used with CustomElements polyfill. --- src/declaration/polymer-element.js | 16 +++++++++++++--- test/js/register.js | 6 ++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/declaration/polymer-element.js b/src/declaration/polymer-element.js index 9989430ec1..fadc396efc 100644 --- a/src/declaration/polymer-element.js +++ b/src/declaration/polymer-element.js @@ -38,9 +38,19 @@ waitPrototype[name] = this; // if explicitly marked as 'noscript' if (this.hasAttribute('noscript')) { - var script = document.createElement('script'); - script.textContent = 'Polymer(\'' + name + '\');'; - this.appendChild(script); + // TODO(sorvell): CustomElements polyfill awareness: + // noscript elements should upgrade in logical order + // script injection ensures this under native custom elements; + // under imports + ce polyfill, scripts run before upgrades + // dependencies should be ready at upgrade time so register + // prototype at this time. + if (window.CustomElements && !CustomElements.useNative) { + element(name); + } else { + var script = document.createElement('script'); + script.textContent = 'Polymer(\'' + name + '\');'; + this.appendChild(script); + } } return; } diff --git a/test/js/register.js b/test/js/register.js index 00ea17f2a4..6bc8c217e9 100644 --- a/test/js/register.js +++ b/test/js/register.js @@ -46,10 +46,8 @@ htmlSuite('element callbacks', function() { htmlTest('html/callbacks.html'); }); -htmlSuite('element script', function() { - htmlTest('html/element-script.html'); -}); - htmlSuite('element registration', function() { + htmlTest('html/element-script.html'); htmlTest('html/element-registration.html'); + htmlTest('html/element-import.html'); });