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

Commit

Permalink
Add a console warning if platform.js is not the first script
Browse files Browse the repository at this point in the history
  • Loading branch information
arv committed Mar 28, 2014
1 parent 93ec905 commit c831128
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions build/if-poly.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ window.logFlags = window.logFlags || {};
o = o.split('=');
o[0] && (flags[o[0]] = o[1] || true);
});
var entryPoint = document.currentScript || document.querySelector('script[src*="platform.js"]');
var entryPoint = document.currentScript ||
document.querySelector('script[src*="platform.js"]');
if (entryPoint) {
var a = entryPoint.attributes;
for (var i = 0, n; i < a.length; i++) {
Expand All @@ -29,13 +30,19 @@ window.logFlags = window.logFlags || {};
// If any of these flags match 'native', then force native ShadowDOM; any
// other truthy value, or failure to detect native
// ShadowDOM, results in polyfill
flags.shadow = (flags.shadow || flags.shadowdom || flags.polyfill);
flags.shadow = flags.shadow || flags.shadowdom || flags.polyfill;
if (flags.shadow === 'native') {
flags.shadow = false;
} else {
flags.shadow = flags.shadow || !HTMLElement.prototype.createShadowRoot;
}

if (flags.shadow && document.querySelectorAll('script').length > 1) {
console.warn('platform.js is not the first script on the page. ' +
'See http://www.polymer-project.org/docs/start/platform.html#setup ' +
'for details.');
}

// CustomElements polyfill flag
if (flags.register) {
window.CustomElements = window.CustomElements || {flags: {}};
Expand Down

0 comments on commit c831128

Please sign in to comment.