Created
March 14, 2016 22:12
-
-
Save justinribeiro/79e860fe4b2bb2fa71c9 to your computer and use it in GitHub Desktop.
Check for need for WebComponents polyfill, use Shadow DOM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var webComponentsSupported = ('registerElement' in document | |
&& 'import' in document.createElement('link') | |
&& 'content' in document.createElement('template')); | |
if (!webComponentsSupported) { | |
var script = document.createElement('script'); | |
script.async = true; | |
script.src = '/bower_components/webcomponentsjs/webcomponents-lite.min.js'; | |
document.head.appendChild(script); | |
window.addEventListener('WebComponentsReady', function(e) { | |
console.log('Fallback time! WebComponentsReady() fired and components ready.'); | |
}); | |
} else { | |
window.Polymer = window.Polymer || {dom: 'shadow'}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment