Fmlib_browser.AttributeSourceAttributes of Dom Elements.
There are four types of attributes:
Sometimes the distinction between properties and attributes is quite subtle. To the best of my knowledge each added attribute adds a property with the same name (except when the name is a javascript keyword like "class") to the html element. But not all properties even if it is a string value adds an attribute to the element.
Type of an attribute potentially generating a message of type 'msg.
style key value Add a style attribute to the html element.
Examples:
style "color" "red"
style "margin" "20px"property key value Add a javascript property to the html element.
attribute key value Add an attribute to the html element.
Examples:
attribute "id" "my_element"
attribute "class" "container"handler event_type stop_flag prevent_flag decoder
Attribute representing an event listener on an html element. The two flags decide if the event is propagated upwards in the dom tree and if default action (some events like clicking on an anchor element cause default actions in the browser) is prevented.
The decoder decodes the javascript event object into a message of type 'msg.
Starting from the event object information from the whole dom tree up to the root can be decode. Each event object has a target (which is the element on which it is fired). The target element has a tag name, can have various properties etc. For more details on event objects see the event api.
More information on event handlers.
map f a Map an attribute creating messages of type 'a to an attribute creating messages of type 'b.
on event_type decoder
is equivalent to handler event_type Event_flag.no_stop Event_flag.no_prevent decoder
Example background_color "powderblue"
Abbreviates style "background-color" "powderblue".
+--------------------------------+
| margin |
| +----border-----------------+ |
| | padding | |
| | +---------------------+ | |
| | | | | |
| | | | | |
| | | content | | |
| | | | | |
| | +---------------------+ | |
| +---------------------------+ |
| |
+--------------------------------+Examples
margin "25px"
margin "25px 50px" top/bottom 25px, left/right 50px
margin "25px 50px 75px 100px" top, right, bottom, leftmargin str abbreviates style "margin" str
Examples
padding "25px"
padding "25px 50px" top/bottom 25px, left/right 50px
padding "25px 50px 75px 100px" top, right, bottom, leftpadding str abbreviates style "padding" str
Examples
border_style "solid"
border_style "dotted"
border_style "dashed"border_style str abbreviates style "border-style" str
Examples
border_width "3px"
border_width "thick"
border_width "medium"The value property of the element (usually an input element)
Each time the user enters something to the input element (text for input type 'text', slider position for input type 'range', date for input type 'date'), the value property changes. Using the value property in the virtual dom overwrites whatever the user has written into the input element. Using a 'value' attribute in the virtual dom does *not* overwrite the user value.