Opinion poll!
You have a <button>, it makes a <foo> open. What would be the best declarative attribute for the button to control the foo?
Opinion poll!
You have a <button>, it makes a <foo> open. What would be the best declarative attribute for the button to control the foo?
@keithamus Is there a reason not to extend the existing `type` attribute?
type=submit
type=reset
type=open (or expand, maybe? if it's expanding something on the current page, to distinguish that from opening a new link)
@sil @AmeliaBR full disclosure; we have a full explainer: https://open-ui.org/components/invokers.explainer/. It allows for `(invent what you like)` (so long as it contains a dash), but it has built-in defaults (which don't contain a dash).
In that regard, `type=whatever-with-dash` would work. If there's a strong desire for it, I can propose it.
@keithamus @sil Oh, if custom types need to be a specific syntax, then that's not a conflict!
I go back to voting for extending type!
`type=widget-play` is a custom extensible behavior that triggers a registered function of some type
`type=play` is something that could be built in for audio and video elements (please!)
But `typetarget` doesn't work for the ID ref, so I don't know about that one. Maybe `buttontarget`?
@AmeliaBR @keithamus @sil One downside to extending type is that unknown types currently fallback to submit buttons. So if we suddenly change the semantics of the type attribute that might break the web...
That's not to say we should never have new types it's just that making type accept anything is probably a non-starter unfortunately.
@Lukew Oh, that's true. If you're adding a custom button within a form, to display a widget or a T&C dialog, you'd want an explicit `type="button"` to be sure a JS error doesn't result in an HTML submit.
(Making submit the default type, instead of button, is definitely one of those errors in the web platform that should be fixed by time machine, IMO.)
@keithamus @sil If it's designed to be an arbitrary name of a function/event to trigger on the other element, then yes, that's a very different API than adding new button types!
I'd go with the `command` / `commandtarget` attributes in that case.
I like the idea of using `action` for consistency, but formaction is a URL, so different.
PS I do hope it will also be possible to use a built-in function as the specified command, like play with a video element target, or open with a dialog target.
@keithamus @AmeliaBR so, there are three possible values for button type. Submit is incompatible with command so you can’t have both at once. Reset “tends to annoy users” (MDN). And “button” doesn’t do anything.
This feels very much suitable for overriding type for command :)