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

IIFE in attributes get incorrectly unwrapped #335

Open
edemaine opened this issue Aug 1, 2024 · 3 comments
Open

IIFE in attributes get incorrectly unwrapped #335

edemaine opened this issue Aug 1, 2024 · 3 comments

Comments

@edemaine
Copy link
Contributor

edemaine commented Aug 1, 2024

Playground link

Input

<For
  each={((s, e) => {
    let step = e > s ? 1 : -1;
    return Array.from(
      { length: Math.abs(e - s) },
      (_, i) => s + i * step,
    );
  })(0, params.boxes)}
/>

(this code may look a bit weird, but it's generated from the simple Civet code <For each=[0...params.boxes]>)

Output

import { createComponent as _$createComponent } from "solid-js/web";
import { For as _$For } from "solid-js/web";
_$createComponent(_$For, {
  get each() {
    let step = e > s ? 1 : -1;
    return Array.from({
      length: Math.abs(e - s)
    }, (_, i) => s + i * step);
  }
});

The bindings for s and e (by the IIFE) got lost. ☹️

This bug seems to go back to at least Solid 1.8.5.

Workaround

Wrap attribute in another IIFE: () => ...

@ryansolid
Copy link
Owner

Yeah that ones a bit odd.. I wouldn't expect the iife to get swallowed since we usually check for argument length, and that clearly has arguments.

@edemaine
Copy link
Contributor Author

edemaine commented Sep 4, 2024

This seems to be fixed by #327. So maybe just needs a release.

@ryansolid
Copy link
Owner

That was released like 7 versions ago. 0.37.22... we are on 0.38.5. The release should have gone out June 25th. Can you confirm if you have it?

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

No branches or pull requests

2 participants