Skip to content

Instantly share code, notes, and snippets.

@rowan-m
Created August 27, 2019 09:13
Show Gist options
  • Save rowan-m/51bfbddd9a419c1d2bdede6cba2d3ad4 to your computer and use it in GitHub Desktop.
Save rowan-m/51bfbddd9a419c1d2bdede6cba2d3ad4 to your computer and use it in GitHub Desktop.
// connectedCallback()
if (!this._container.part) {
// create a <span>
const wrapper = document.createElement('span');
// move this element's child nodes into it
wrapper.append(...this.childNodes);
// add the classes
wrapper.classList.add('fallback');
this.classList.add('fallback');
// and add the wrapper into this element
this.append(wrapper);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment