-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
I am trying to create a custom web component that takes attributes:
[<LitElement("fluent-icon")>]
let FluentIcon() =
let _, props =
LitElement.init(fun init ->
init.useShadowDom <- false
init.props <-
{|
name = Prop.Of(defaultValue = "Add", attribute = "name")
size = Prop.Of(defaultValue = "20px", attribute = "size")
color = Prop.Of(defaultValue = "red", attribute = "color")
|}
)
let name = props.name.Value
let color = props.color.Value
let size = props.size.Value
html $"""<i class="ms-Icon ms-Icon--{name}" style="color: {color}; font-size: {size};" aria-hidden="true"></i>"""Usage:
<fluent-icon name="Add" color="Red" size="20px"></fluent-icon>It works if I use static html with no inputs, but adding the the 3 input attributes: init.props <- {| ... |} results in the following error:
LitElement.fs:275
Uncaught TypeError: Cannot set property name of #<classExpr> which has only a getter
at LitElement.fs:275:35
at Seq.js:837:9
at fold (Seq.js:691:19)
at iterate (Seq.js:836:5)
at initProps (LitElement.fs:274:40)
at new LitHookElement$1 (LitElement.fs:185:8)
at new classExpr (LitElement.fs:288:29)
at TemplateInstance._clone (lit-html.ts:927:52)
at ChildPart._commitTemplateResult (lit-html.ts:1270:33)
at ChildPart._$setValue (lit-html.ts:1165:12)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels