Skip to content

Instantly share code, notes, and snippets.

@jdvivar
Created June 2, 2021 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdvivar/2c715277d02e04eb785031fb2ff34241 to your computer and use it in GitHub Desktop.
Save jdvivar/2c715277d02e04eb785031fb2ff34241 to your computer and use it in GitHub Desktop.
Dedupe customElements definitions
export function customElementDedupe(): void {
const define: Function = window.customElements.define.bind(window.customElements);
window.customElements.define = (
name: string,
constructor: Function,
options: object,
): void => {
if (!window.customElements.get(name)) define(name, constructor, options);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment