Closed trg closed 6 years ago
@trg because changing this right now could potentially break things for users relying on passing style
and class
as is we can revisit this change when we are ready for a Marko 5 release. Thanks for creating the issue and we'll let you know when we are closer to a new release.
Fixed in 4.11
(without breaking since we only target HTML elements)
New Feature
Description
When using dynamic input attributes such as the example in the doc: https://markojs.com/docs/syntax/#dynamic-attributes
<a ${myDynamicInputObject} target="_blank">eBay</a>
The special processing that is done to the
class
andstyle
when those attributes are an object is ignored byhelper-attrs
. IfmyDynamicInputObject
above has aclass
orstyle
key, I'd expect Marko to process that attribute as it does if it was hardcoded.Why
The only way to deal with dynamic style or class attributes is a workaround like this:
Possible Implementation & Open Questions
Assuming no circular dependencies, adding a check above here for these special inputs may be a fix: https://github.com/marko-js/marko/blob/master/src/runtime/html/helper-attr.js#L18
I wanted to touch base here though in case there's a reason that class / style are being serialized if the input is dynamic.
Is this something you're interested in working on?
Yes