Skip to content

Commit

Permalink
noscript should now work better when used with CustomElements polyfill.
Browse files Browse the repository at this point in the history
  • Loading branch information
sorvell committed Aug 14, 2013
1 parent 0565e22 commit 38ce9b4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
16 changes: 13 additions & 3 deletions src/declaration/polymer-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 2 additions & 4 deletions test/js/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

0 comments on commit 38ce9b4

Please sign in to comment.