Last active
December 15, 2025 16:57
-
-
Save adactio/a445544723363d37b9c31a74a03ef928 to your computer and use it in GitHub Desktop.
Web Install HTML web component
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That querySelector will only get a
<button>when the Web Component is defined after (light)DOM parsed.When defined before lightDOM is parsed; ie. in the
<head>(to prevent those FOUC issues)querySelectorwill returnnullBecause the connectedCallback runs on the opening tag (before lightDOM is parsed),
you need to wait a tick before querying the lightDOM.
I made it a (HTML) Web Component, so it also works when its not a HTML Web Component (user added
<button>)