3 ms·
> Bit surprised htmx falls into the XML nostalgia trap. As the article states, the only tag that can't be searched for via CSS selectors is the new "hx-on". A
by listenallyall 3y ago
> Bit surprised htmx falls into the XML nostalgia trap.
As the article states, the only tag that can't be searched for via CSS selectors is the new "hx-on".
And my initial thought about this is (which I'm open to reconsider), it seems like you probably shouldn't go looking for elements based on their event model. Show me every <div> with a certain value in its class attribute? Yes of course. But find me every <div> with a certain behavior on mouseUp? This isn't something you'd do in an OO language, you'd look for objects with a certain property value, not a specific event handler, which would likely be private anyway.
I'd also note that, for the same reason, standard HTML as well as React, etc have the same inability as HTMX here. The article notes that with HTMX you can't use CSS selectors to find "hx-on(something)" tags, the same handicap prevents you from searching for any element with an "on(something)" attribute, i.e. onClick, onMouseUp, onKeyPress etc.
Maybe I haven't thought through this entirely but I don't see any problem here.
(edit: to be clear, of course you can CSS-select a specific tag like onClick, and you can also select a specific HTMX tag like hx-on:click. What the article notes that you cannot do is search via wildcards or "starts-with" in CSS, i.e. hx-on:*, but you can't do on* either)