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

remove unreferenced variable from initial context #4941

Conversation

tanhauhau
Copy link
Member

@tanhauhau tanhauhau commented May 31, 2020

if you look at the output of the following:

<script>
  let foo;
  function unreferenced () {
    foo = 1;
  }
</script>
<button on:click={() => foo = 2}></button>

REPL

you would notice instance is returning [foo, unreferenced, click_handler], unreferenced is part of the array, but it is not referenced anywhere in the fragment.

this change removes it:

- return [foo, unreferenced, click_handler];
+ return [foo, click_handler];

Additional changes

  • the calculation of initial_context is shifted from src/compiler/compile/render_dom/index.ts to src/compiler/compile/render_dom/Renderer.ts closer to the logic of sorting of context

@Conduitry Conduitry merged commit c21a42e into sveltejs:master Jun 8, 2020
@tanhauhau tanhauhau deleted the tanhauhau/remove-unreferenced-function-from-initial-context branch June 9, 2020 00:38
taylorzane pushed a commit to taylorzane/svelte that referenced this pull request Dec 17, 2020
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.

None yet

2 participants