domafic-rs icon indicating copy to clipboard operation
domafic-rs copied to clipboard

Attributes vs. Properties

Open cramertj opened this issue 7 years ago • 2 comments

Currently, there's no distinction between attributes and properties-- attributes are used as attributes in HTML and as properties in the browser. This is necessary for things like "value" to work-- setting the "value" attribute in the browser doesn't change the content, and it's not possible to set properties in HTML AFAIK. However, this causes weirdness for things that have both an attribute and property with different names, such as "class" and "className". Elm special-cases a bunch of these names in order to apply them differently, but that's really messy. Attribute/property keys could be changed to an enum and matched on, but this has the unfortunate side effect of restricting keys to a predefined set, as well as requiring an import for each attribute used.

cramertj avatar Jan 14 '17 00:01 cramertj

After some thought, I'm probably just going to special-case certain strings, ala Elm. It's the easiest on users of the library, and it only imposes a tiny runtime cost (a single match statement).

cramertj avatar Jan 19 '17 00:01 cramertj

an enum seems to be the way to go design-wise. it would not restrict to a predefined set, if you add one variant to the enum typed Other(String).

iqualfragile avatar Jan 29 '17 13:01 iqualfragile