Skip to content

Instantly share code, notes, and snippets.

@nolanlawson
Created August 4, 2022 19:16
Show Gist options
  • Save nolanlawson/94e65587635ad5249525ffec4472a658 to your computer and use it in GitHub Desktop.
Save nolanlawson/94e65587635ad5249525ffec4472a658 to your computer and use it in GitHub Desktop.
Detecting customelements define extends
// Via https://github.com/ungap/custom-elements/blob/bdb7c27/index.js#L428-L456
const SUPPORTS_EXTENDING_BUILT_IN_ELEMENTS = (() => {
const tagName = `extends-li-${Math.floor(Math.random() * 1000000)}`;
self.customElements.define(tagName, class extends HTMLLIElement {}, { extends: 'li' });
const elm = document.createElement('li', { is: tagName });
return elm.outerHTML.indexOf(tagName) !== -1;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment