-
Notifications
You must be signed in to change notification settings - Fork 98
Use attributes instead of properties #259
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
base: master
Are you sure you want to change the base?
Conversation
downloadAs : String -> Attribute msg | ||
downloadAs = | ||
stringProperty "download" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was unused (not exposed).
value string = | ||
-- Note: `.value` has no corresponding attribute, so we have to set it | ||
-- using a property. It can also be modified by the user by typing in inputs. | ||
-- Properties are diffed against the actual DOM, not the virtual DOM, so | ||
-- this ensures that the DOM is up-to-date with the model. | ||
Elm.Kernel.VirtualDom.property "value" (Json.string string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
value
is an exception where we have to use a property, not an attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Properties are diffed against the actual DOM, not the virtual DOM, so this ensures that the DOM is up-to-date with the model.
This refers to the implementation in elm/virtual-dom#187
Intro
This PR is a companion to elm/virtual-dom#187. That elm/virtual-dom PR works without this elm/html PR, but virtualization won’t work 100 % without it.
This PR removes the
stringProperty
helper function, and uses attributes for the exposed functions that used it instead. TheboolProperty
function is kept, and I added a comment for why.Details
Most functions in
Html.Attributes
that take aString
used this helper function:For example,
href
:In other words, lots of the
Html.Attributes
functions were implemented by setting properties.This PR removes
stringProperty
, and instead prefers attributes over properties. Here’shref
in this PR:In short, attributes are preferred because:
Html.Attributes
functions are attributes. Closes elm/virtual-dom#144I explain those points more in the
properties-vs-attributes.md
file (which I updated in this PR).