Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support spread in attributes #878

Closed
mlrawlings opened this issue Oct 5, 2017 · 0 comments
Closed

Support spread in attributes #878

mlrawlings opened this issue Oct 5, 2017 · 0 comments
Assignees
Labels
Milestone

Comments

@mlrawlings
Copy link
Member

New Feature

Description

Support the spread operator in tag attributes.

<tag ...attrs/>

Why

We currently support two ways of passing dynamic attributes to a tag:

<custom-tag(input.attrs) data-foo=input.foo/>
<custom-tag ${input.attrs} data-foo=input.foo/>

Attributes should be the only way in which we pass data into tags (except for a few exceptions like if and for). The spread attribute is soon to be a JS standard and has a major benefit over the current solutions: order matters.

Using the parens as a tag argument (<custom-tag(input.attrs)/>) prevents you from ordering and even <custom-tag ${input.attrs}/> which could support ordering, doesn't.

Ordering gives you the ability to assign precedence, to create both default values and override values.

<custom-tag foo="default" ...input bar="override"/>

As a side note, the parens as an argument don't work for regular dom tags.

// no matter what `input.attrs` is, all you get is `<div data-foo>`
<div(input.attrs) data-foo=input.foo/>
@mlrawlings mlrawlings added the type:feature A feature request label Oct 5, 2017
@mlrawlings mlrawlings added this to the Tag Params milestone Oct 5, 2017
@mlrawlings mlrawlings self-assigned this Oct 5, 2017
@mlrawlings mlrawlings mentioned this issue Oct 5, 2017
DylanPiercey pushed a commit that referenced this issue Feb 7, 2018
* add spread operator and update docs.
@mlrawlings mlrawlings mentioned this issue Jul 4, 2018
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant