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

Fixed bug with slot props variables #3122

Closed
wants to merge 1 commit into from

Conversation

primos63
Copy link

#2586

Fixes issue when declaring and initializing a variable used in a slot.
The variable is hoisted and subsequently not added to filtered_declarations. The return statement for the component instance would be
return { $$slots, $$scope };

when it should be
return { worldText, $$slots, $$scope };

Test component-slot-let-e will fail when worldText is not part of the return object.

1) runtime
      component-slot-let-e :

     AssertionError [ERR_ASSERTION]: '<div><p>undefined</p></div>' deepEqual '<div><p>foo</p></div>'
     + expected - actual

     -<div><p>undefined</p></div>
     +<div><p>foo</p></div>
     
     at Function.assert.htmlEqual (test/helpers.js:141:10)
     at Promise.resolve.then (test/runtime/index.js:155:14)

Other slot tests did not fail because the on:click handler caused the variable to be not be hoisted.

@Rich-Harris
Copy link
Member

Thank you! There's actually a slightly more efficient fix, which is to re-use the hoisted value (and not shadow it) — I've opened #3124 (which is a branch off this PR), so will close this

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