Created
June 2, 2021 14:58
-
-
Save jdvivar/2c715277d02e04eb785031fb2ff34241 to your computer and use it in GitHub Desktop.
Dedupe customElements definitions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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