Skip to content

Instantly share code, notes, and snippets.

@MarkTiedemann
Created September 30, 2024 07:19
Show Gist options
  • Save MarkTiedemann/d4c9b736707a612f4c14d548af693377 to your computer and use it in GitHub Desktop.
Save MarkTiedemann/d4c9b736707a612f4c14d548af693377 to your computer and use it in GitHub Desktop.
const originalAttachShadow = Element.prototype.attachShadow;
Element.prototype.attachShadow = function attachShadow(...args) {
const detail = originalAttachShadow.apply(this, args);
this.dispatchEvent(new CustomEvent("shadowRootAttached", { detail }));
return detail;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment