Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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