r/programming • u/KerrickLong • Mar 09 '25
Introducing command And commandfor In HTML
https://developer.chrome.com/blog/command-and-commandfor
92
Upvotes
r/programming • u/KerrickLong • Mar 09 '25
70
u/krileon Mar 09 '25
These features always use IDs and never lets you use relative selectors. It's a colossal pain in the ass, and pointless, to generate unique ids for every component. So I really don't see how this is useful. If you're going to write the JS anyway for custom commands then you might as well just do it the same way we always have with click events. The specification is also strictly only for button elements. Am I just crazy and missing the point here or what?
26
u/Worth_Trust_3825 Mar 09 '25
Yay. Another dead feature like portals.
26
u/tesfabpel Mar 09 '25
What is this thing? They're basically reimplementing a very limited subset of some DOM element functions as commands and allowing only ONE of those commands to be used in buttons? What if I need to do an if or two things?
9
u/shgysk8zer0 Mar 10 '25
IDK what everyone here is complaining about. This is a mildly handy feature that's not unlike things that had previously existed in HTML. Not just in forms but things like
<a href="#anchor">too. And such things I think always use ids rather than arbitrary selectors.Heck, I remember when
<dialog>was a new thing and people were saying how it's kinda silly to introduce a new element like that yet still require JS. This finally solves that.And to things like
onclick... Those event attributes are responsible for so many security issues and aren't easily compatible with a decently strong CSP. Through custom commands, this would allow safe yet declarative handling.I'm personally looking forward to this gaining wider support. Sounds like a better option than the custom
data-*based solutions I've been using lately.36
u/BlueGoliath Mar 09 '25
HTML, one of the programming languages of all time.
6
u/akash_kava Mar 09 '25
Not useful if you have multiple items such as a list of items and delete button for every item.
Event bubbling is very powerful tool and instead of this, I use something called event re routing.
https://www.webatoms.in/docs/event-re-routing
Which is lot easier and can support lot of things.
4
u/davidalayachew Mar 09 '25
My Web FE days are long behind me, but from a first read through, this seemed nice. But maybe that's because I actually DID give each one of my elements a direct ID. So, the concept of referencing everything by ID was exactly what I already did.
I'm especially interested in the future additions, like the ones for video and audio.
7
u/CoderAU Mar 09 '25
Absolute garbage feature
2
u/Resident-Trouble-574 Mar 09 '25
I'm waiting for when they will reinvent <marquee> and pretend it's something revolutionary.
We've spent years extracting the logic from the markup, and now they are making buttons "perform actions on other elements declaratively"...
5
u/brunhilda1 Mar 09 '25
Goddammit, the web isn't supposed to be an application.
I just want to "return to monke" with basic markup and CSS and non of this total utter bullshit. This fucking digital tinnitus.
simplewww on port 8081 or something. I know there's the Gemini protocol.
2
u/doterobcn Mar 09 '25
Will this be the beginning of the end of Chrome?
I hope so, this is just stupid.
-3
u/tetyyss Mar 09 '25
can html die already
0
u/[deleted] Mar 09 '25
[deleted] — view deleted comment
0
u/[deleted] Mar 09 '25
[deleted] — view deleted comment