Skip to content

Support root-level attributes, close #32 #36

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

Merged
merged 1 commit into from
Jan 6, 2019

Conversation

nickmessing
Copy link
Member

Allow people to use syntax like:

export default {
  render() {
    return <MyComponent props={{ prop: 'value' }} />
  }
}

@@ -301,6 +301,21 @@ render(h => h("div", _mergeJSXProps([{}, spread, {
}
});`,
},
{
name: 'Root attribute',
from: `<MyComponent propsProp1="foo" props={{ prop1: 'alpha', prop2: 'beta' }} />`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming propsProp1="foo" is same as props={ prop1: 'foo' }.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the generated code depend on prop order?

<MyComponent props={{ prop1: 'alpha', prop2: 'beta' }} propsProp1="foo" />

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@znck, yes, it will be merged in the end to something that behaves like:

{
  ...{ prop1: 'alpha', prop2: 'beta' }
  ...{ prop1: 'foo' }
}

Just like it normally would work if you declare a JS object with same key twice...

@znck
Copy link
Member

znck commented Jan 2, 2019

Could you please explain the requirement in detail?

@nickmessing nickmessing merged commit b0bc857 into dev Jan 6, 2019
@nickmessing nickmessing deleted the feat/support-root-attributes branch January 6, 2019 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants