melt-ui / preprocessor

19 stars 4 forks source link

🐛Bug: Handle expressions that don't reference any variables within their blocks #31

Closed AdrianGonz97 closed 1 year ago

AdrianGonz97 commented 1 year ago

The range slider is broken because it doesn't reference the context ( _ ) of the EachBlock, thus hoisting the thumb() function to the script. What we want is to have the thumb() function be assigned with the @const tag in its EachBlock instead.

{#each $value as _}
    {@const __MELTUI_BUILDER_0__ = $thumb()}
    <span
        {...__MELTUI_BUILDER_0__} use:__MELTUI_BUILDER_0__.action
        class="block h-5 w-5 rounded-full bg-white focus:ring-4 focus:ring-black/40"
    />
{/each}