jridgewell / babel-plugin-transform-incremental-dom

Turn JSX into IncrementalDOM
MIT License
145 stars 12 forks source link

Array return misidentifies static attributes #96

Closed mgarber93 closed 6 years ago

mgarber93 commented 6 years ago

When returning an array, the transpiled code returns an array with only the first element invoked with arguments. The rest of the array attempts to access the arguments via a statics array (see line 16 and 33: Uncaught ReferenceError: bar is not defined).

Strangely, I have been able to work around this issue by trying to use tagged templates. This jsx:

    ...
    const workAround = t => t;
    return ([
      <span
        foo={ workAround`My bar is: ${bar}`}
      >one</span>,
      <span
        foo={ workAround`My bar is: ${bar}`}
      >two</span>,
      <span
        foo={ workAround`My bar is: ${bar}`}
      >three</span>
    ]);
    ...

transpiles to return an array where each jsxWrapper is invoked with the correct arguments:

return [_jsxWrapper(_span$wrapper, [workAround(_templateObject, bar)]), _jsxWrapper(_span$wrapper2, [workAround(_templateObject, bar)]), _jsxWrapper(_span$wrapper3, [workAround(_templateObject, bar)])];
jridgewell commented 6 years ago

Should be fixed in v4.2.1

mgarber93 commented 6 years ago

Looks good, thanks @jridgewell !