I'm trying to create a form in Marko and for the inputs I'm using a component that will create the inputs and will handle the validation. The hole problem is when I try to pass an event listener as a dynamic attribute.
I have an array of fields as objects, containing the type, id and, if the field has to be checked, an attribute object with the handler function.
$ const fields= [
{
type: 'email',
id: 'exampleEmail',
atrrs: {
'on-change' : 'check'
}
'},
.
.
.
]
<for|field| of=fields>
<input type=`${field.type}` id=`${field.id}` ...field.attrs>
</for>
The output should be:
<input type='email' id='exampleEmail' on-change('check')>
But instead I'm having:
<input type='email' id='exampleEmail' on-change='check'>
And if I try to pass the attribute as a string instead of an object I get a Migration and a deprecation warning:
MIGRATION The "${attributes}" is deprecated. Please use "...attributes" modifier instead
WARNING!!
"Passing a string as dynamic attributes ('<div ${string}>' or '<div ...string>'
) is deprecated, use an object instead."