Skip to content

Instantly share code, notes, and snippets.

@tbranyen tbranyen/

Created May 29, 2017
What would you like to do?
Web Components <3 JSDOM
npm i jsdom-wc@11.0.0-alpha-1
const { JSDOM } = require('jsdom-wc');
const { window } = new JSDOM(`<!DOCTYPE html>`);
Object.assign(global, {
document: window.document,
HTMLElement: window.HTMLElement,
customElements: window.customElements,
class BoldComponent extends HTMLElement {
connectedCallback() {
this.innerHTML = `<b>${this.innerHTML}</b>`;
customElements.define('bold-component', BoldComponent);
document.body.innerHTML = `
<bold-component>What a time to be...</bold-component>
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.