Is there a way to append IProp
's to HTML
?
Here's an example of what i'm trying to do:
foo :: forall p i. H.HTML p i -> H.HTML p i
foo myElement =
addProp (HP.id_ "SomeId") myElement
Where addProp
takes myElement
, gives it the Id
(or any other arbitrary property) and returns back this new element that is basically the same but has that new property added to it?
Or in other words, does this function addProp
exist in some fashion?
It doesn't exist no, as if it were to do so, it'd bypass the typechecking of valid properties that can be set on a given element, plus it'd let you say nonsensical things like addProp
on a HH.text
value.
It's not impossible to write though, as the property checking stuff isn't an intrinsic part of the HTML
representation - it's a layer on top that refines it. HTML
is just made up of normal data types, so you can pattern match on HTML
values to manipulate as needs be.