You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to see a template element like <MyComponent {{myObject}}> take all the properties of the tag's value and apply them to the element as attributes, e.g. if myObject is {foo: "mario", bar: "luigi"}, then the element is equivalent to <MyComponent foo="mario" bar="luigi">.
Use cases for this include tree node components, which could specify their children be displayed like so...
{{#each children as childData}}
<:Self {{childData}}/>
{{/each}}
...and dynamic components, which may need to send arbitary data to their arbitrary component.
<:Component {name} {{data}}/>
I'd be okay with this being forbidden for non-component elements and/or not allowed to mix with any other attributes.
The text was updated successfully, but these errors were encountered:
I think this has come up a few times, #195 might be the earliest one. I recall there's been resistance to this feature before (I think from this making it impossible to do certain types of compile-time optimizations?), but I don't remember exactly what the problem was. Probably because it makes it harder to update just the relevant attributes in the child, and to watch just the relevant things in the parent.
Without being familiar with the Svelte codebase, I'd speculate that if we allowed only a property name and not an arbitrary expression, and forbade any other attributes on the element, then it becomes a simple matter of just doing .set(myObject) whenever myObject changes.
At that point, we'd probably need non-double-bracket syntax to keep the double-bracket rules simple, perhaps <MyComponent data:myObject>.
Should I repost the use cases and/or this comment to #195, and let this be closed as a duplicate?
I'd like to see a template element like
<MyComponent {{myObject}}>
take all the properties of the tag's value and apply them to the element as attributes, e.g. ifmyObject
is{foo: "mario", bar: "luigi"}
, then the element is equivalent to<MyComponent foo="mario" bar="luigi">
.Use cases for this include tree node components, which could specify their children be displayed like so...
...and dynamic components, which may need to send arbitary data to their arbitrary component.
I'd be okay with this being forbidden for non-component elements and/or not allowed to mix with any other attributes.
The text was updated successfully, but these errors were encountered: