| Copyright | (C) 2016-2026 David M. Johnson |
|---|---|
| License | BSD3-style (see the file LICENSE) |
| Maintainer | David M. Johnson <code@dmj.io> |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Miso.Property
Contents
Description
Overview
Miso.Property provides the low-level primitives for constructing
Attribute values that set DOM properties on virtual nodes.
All higher-level property combinators in Miso.Html.Property,
Miso.Svg.Property, and Miso.Mathml.Property are built on top of
these.
The central combinator is prop:
prop::ToJSONa =>MisoString-> a ->Attributeaction
It wraps any JSON-serialisable value as a Property node,
which the virtual DOM diffs and writes to the DOM node only when the
value changes.
Typed convenience wrappers
textPropMisoString—textProp"placeholder" "…"stringPropString—stringProp"lang" "en"boolPropBool—boolProp"checked" TrueintPropInt—intProp"tabIndex" 3integerPropInteger—integerProp"size" 10doublePropDouble—doubleProp"volume" 0.8objectPropObject—objectProp"dataset" obj
Class list
classList stores CSS class names as a deduplicated list rather than a
single concatenated string. The virtual DOM diffing engine handles the
list directly so individual class additions and removals are efficient:
classList ["btn", "btn-primary"]
Virtual DOM keys
key_ (alias keyProp) attaches a reconciliation key to a node, telling
the differ which old and new nodes correspond to each other in a dynamic
list:
ul_[] [li_[key_item.id ] [textitem.label ] | item <- items ]
See also
- Miso.Html.Property — named HTML property combinators built on this module
- Miso.Svg.Property — SVG property combinators
- Miso.Mathml.Property — MathML property combinators
- Miso.Types —
Attribute,Key,ToKey
Synopsis
- prop :: ToJSON a => MisoString -> a -> Attribute action
- classList :: [MisoString] -> Attribute action
- textProp :: MisoString -> MisoString -> Attribute action
- stringProp :: MisoString -> String -> Attribute action
- boolProp :: MisoString -> Bool -> Attribute action
- intProp :: MisoString -> Int -> Attribute action
- integerProp :: MisoString -> Integer -> Attribute action
- doubleProp :: MisoString -> Double -> Attribute action
- objectProp :: MisoString -> Object -> Attribute action
- keyProp :: ToKey key => key -> Attribute action
- key_ :: ToKey key => key -> Attribute action
Smart constructors
Arguments
| :: ToJSON a | |
| => MisoString | DOM property name (e.g. |
| -> a | Property value; serialised to JSON before diffing |
| -> Attribute action |
prop k v is an attribute that will set the attribute k of the DOM
node associated with the vnode to v.
classList :: [MisoString] -> Attribute action Source #
Smart constructor for specifying 'class'
Since: 1.9.0.0
Arguments
| :: MisoString | DOM property name |
| -> MisoString | Property value |
| -> Attribute action |
Set field to MisoString value
Arguments
| :: MisoString | DOM property name |
| -> String | Property value |
| -> Attribute action |
Set field to String value
Arguments
| :: MisoString | DOM property name |
| -> Bool | Property value |
| -> Attribute action |
Set field to Bool value
Arguments
| :: MisoString | DOM property name |
| -> Int | Property value |
| -> Attribute action |
Set field to Int value
Arguments
| :: MisoString | DOM property name |
| -> Integer | Property value |
| -> Attribute action |
Set field to Integer value
Arguments
| :: MisoString | DOM property name |
| -> Double | Property value |
| -> Attribute action |
Set field to Double value
Arguments
| :: MisoString | DOM property name |
| -> Object | JSON object value |
| -> Attribute action |
Set field to Object value