Hacker Newsnew | past | comments | ask | show | jobs | submit | rasso's commentslogin

See my other comment: you can set default styles using

:where(:not(:defined)) { display: block }


simply only ever use this to replace <span> or <div>


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.


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.


This is how you can set default styles for all your custom elements:

    :where(:not(:defined)) {
         display: block;
    }


Amazing, I was literally just trying to see if I could figure out how to do this. Thanks!


Amazing, thanks! Didn't know this one yet :)


Absolutely, me too!! AS3 was a beautiful language.


It‘s not by the vite team.



Oh my… thanks for the research and sorry for my lazy assumption!


Beautiful! If you could find a way to connect this to Music for Programming [0], that would be awesome.

[0] https://musicforprogramming.net/latest/


Good idea. I don’t know how to hook it up exactly, but I can add this type of music.


Interesting - not available for me (in Germany!)…


It's a ZDF documentary, I imagine DW only got the rights to show the translation outside of Germany.

Here's a link to the original: https://www.zdf.de/video/dokus/megacitys-wenn-es-nacht-wird-...



Alpine.js in tandem with alpine-ajax has made me a very happy developer the last few years.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: