News for hackers. Stuff that matters.
Re:You can make up HTML tags by rasso on Monday December 29, 2025 @12:54AM (#46417871)
Beware that connectedCallback runs _every time_ a custom element is added to the dom. So you should make sure to only add event listeners once by tracking internally if the element was already initialized.
Re:You can make up HTML tags by yawaramin on Monday December 29, 2025 @09:51PM (#46428987)
Thanks, that's good to know. In some contexts I don't think a custom element is ever added to the DOM more than once, eg in htmx I am responding with HTML markup which is then injected into the page and then just kept there, possibly 'forever' or at least until it is replaced by some new markup from a new response.