jsxobj icon indicating copy to clipboard operation
jsxobj copied to clipboard

Support single element or top level arrays

Open texastoland opened this issue 3 years ago • 0 comments

Building on @theianjones's proposal in #3.

1 open question is how to represent an array with a single element. The only idea I had was fragments like <>...</>. But that would be a separate PR anyway.

Given a component-like function:

const Aliases = () => (
  <>
    <alias from="react" to="preact-compat" />
    <alias from="react-dom" to="preact-compat" />
  </>
)

Expect <Aliases/>:

[
  {
    // name: "alias",?
    from: "react",
    to: "preact-compat",
  },
  {
    // name: "alias",?
    from: "react-dom",
    to: "preact-compat",
  },
]

Given:

const Resolve = () => (
  <resolve>
    <>
      <alias from="react-dom" to="preact-compat" />
    </>
  </resolve>
)

Expect <Resolve/>:

{
  name: "resolve",
  alias: [
    {
      from: "react-dom",
      to: "preact-compat",
    },
  ],
}

texastoland avatar Jan 26 '22 07:01 texastoland