Skip to content

Instantly share code, notes, and snippets.

@cayblood cayblood/polymer_setup.js
Last active Jan 17, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.