-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support attributes in options #208
Comments
Issues and PRs related to this topic:
|
Currently exposed attributes:
Button, Menu, Toggles, both have "disabled", but I don't think we should think of those as attributes. Helpers also expose a few, but let's disregard those for now; they're for internal use anyway. (I might have missed a few.) |
One thing that I think needs to be considered that if we were to remove the restrictions from |
That might get fixed considering the talk on the dev mailing list. They are looking at Html itself being able to take lists of attributes and be able to combine them properly. :-) For now though, what about an 'arbitrary attribute' constructor for Options? Say it takes a function that takes a value(s) and returns an attribute, that would allow for being able to test and combine what you need. Could be used kind of like: Options.attrWrap Textfield.Outer Html.Attribute.id "some-id"
Options.attrWrap Menu.InnerDiv Html.Events.onClick MyClickMsg The first argument species the type, which can hold the config struct for the given item and thus do checking on it and return the final value that is either combined into the config or stored in it as a raw attribute if it is one that is not cared about. Hmm, that is if function pointers are comparable in Elm... which I do not think so now that I think of it... Higher types could solve it too, but do not have those either... Blehg... We really need to be able to see the Property type and introspect it, hate stupid hiding of needed things... |
On one hand I think we could open up I think we could possibly mitigate this by ensuring that all |
Hmm, that last suggestion might be the best work-around for now (with a note that custom settings may get overwritten). If Html.Attributes gets repeatable things added soon, which it looks like it might, that is best. Could also send a PR to Html core to make Property fully public so it can be introspected too. |
I believe problem with the |
Considering I want the virtual-dom to be inspectable in its entirety... ;-) Making a server-side elm renderer requires native code to inspect the virtual-dom right now, it is a pain, all because it is so opaque. |
While experimenting with this particular issue I came upon certain discrepancies between our -- This one outputs <div id="div-3"></div>
Html.div
[ Html.Attributes.id "div-1"
, Html.Attributes.id "div-2"
, Html.Attributes.id "div-3"
]
[]
-- This one outputs <div id="div-4"></div>
Options.styled Html.div
[ Options.attribute <| Html.Attributes.id "div-4"
, Options.attribute <| Html.Attributes.id "div-5"
, Options.attribute <| Html.Attributes.id "div-6"
]
[]
-- This one outputs <div id="div-7"></div>
Options.styled' Html.div
[ Options.attribute <| Html.Attributes.id "div-7"
, Options.attribute <| Html.Attributes.id "div-8"
]
[ Html.Attributes.id "div-9" ]
[] Now I'm not sure if this is actually an issue, as setting the same attribute several times should not really happen, but I thought it's worth mentioning. |
I like opening for arbitrary attributes with a big disclaimer. We need to reopen the Dispatch PR and support custom events first, though, because this is what people will do with it in the vast majority of cases. I don't want people to have the disappointment of first thinking they can have the event handlers they need with attribute, then discover they can't do it without breaking elm-mdl. |
I like @vipentti's experiment. We should
(Lot of work in the last one. May not be worth it.) |
I think the second part is not actually as bad as it may seem. If we do this in |
Uh! Exciting! Looking forward to seeing it! |
Options currently support
Html.Attribute.attribute
only onStyle m
options. Other components laboriously wrap parts ofHtml.Attribute
inOptions
to allow users customisation of various sorts. We need the latter to protect ourselves from users breaking elm-mdl by overriding important attributes, usuallyon "..."
.Wrapping
Html.Attribute
is suspect because (a) it seems wasteful and inelegant the more attributes we add, and (b) we end up in situations where distinct components need the same attribute wrapped, and currently have no good solution for that. See #201.I'd like to discuss whether the current approach of wrapping
Html.Attribute
values is the way forward, or if we should aim for something more general.For starters, let's make a list of attributes currently supported and missing.
The text was updated successfully, but these errors were encountered: