Last active
January 17, 2019 13:33
-
-
Save cayblood/2ed3f51e88af21bd022c to your computer and use it in GitHub Desktop.
Adding custom elements needs to wait until after polymer-ready
This file contains 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
// 1. Load Polymer before any code that touches the DOM. | |
var script = document.createElement("script"); | |
script.src = "/base/bower_components/webcomponentsjs/webcomponents.js"; | |
document.getElementsByTagName("head")[0].appendChild(script); | |
// Delay Jasmine specs until WebComponentsReady | |
var POLYMER_READY = false; | |
beforeEach(function(done) { | |
window.addEventListener('polymer-ready', function () { | |
// import custom elements | |
var link = document.createElement("link"); | |
link.rel = "import"; | |
link.href = "/base/elements/twt-user-badge.html"; | |
document.getElementsByTagName("head")[0].appendChild(link); | |
POLYMER_READY = true; | |
done(); | |
}); | |
if (POLYMER_READY) done(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment