Skip to content

Instantly share code, notes, and snippets.

@cayblood
Last active January 17, 2019 13:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cayblood/2ed3f51e88af21bd022c to your computer and use it in GitHub Desktop.
Save cayblood/2ed3f51e88af21bd022c to your computer and use it in GitHub Desktop.
Adding custom elements needs to wait until after polymer-ready
// 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