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

deconflict binding this variable #4949

Merged

Conversation

tanhauhau
Copy link
Member

@tanhauhau tanhauhau commented Jun 1, 2020

Build on top of https://github.com/sveltejs/svelte/pull/4861/commits, contain #4861 changes on bind:this.

opposed to #4792, this MR tries to get unique name for bind:this variable, instead of inline component variable

note: aware of variable merging logic in #4759

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR relates to an outstanding issue, so please reference it in your PR, or create an explanatory one for discussion. In many cases features are absent for a reason.
  • This message body should clearly illustrate what problems it solves. If there are related issues, remember to reference them.
  • Ideally, include a test that fails without this PR but passes with it. PRs will only be merged once they pass CI. (Remember to npm run lint!)

Tests

  • Run the tests tests with npm test or yarn test)

@tanhauhau tanhauhau changed the title Tanhauhau/deconflict binding this variable deconflict binding this variable Jun 1, 2020
@Conduitry
Copy link
Member

@tanhauhau Can you take a look at the merge conflicts here please? Most of them are caused by me renaming bindingGroups to binding_groups as I merged #4861 - but a few are unrelated to that and I'm not sure how you want them handled.

@tanhauhau tanhauhau force-pushed the tanhauhau/deconflict-binding-this-variable branch from 5c91b30 to 4f9a567 Compare June 9, 2020 01:11
@tanhauhau
Copy link
Member Author

@Conduitry conflicts resolved

@Conduitry
Copy link
Member

It might not matter after minification, but is there a reason in the compiled code that this is splitting const foo = bar into let foo and foo = bar?

@@ -133,6 +133,7 @@ export default class InlineComponentWrapper extends Wrapper {
const { component } = renderer;

const name = this.var;
block.add_variable(name);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, @Conduitry , I'm adding block.add_variable(name) here so that the later on bind:this will notice that this variable name has been used.

Copy link
Member Author

@tanhauhau tanhauhau Jun 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this happens for elements as well:

this.add_variable(id);

@Conduitry Conduitry merged commit 7dfd9e9 into sveltejs:master Jun 10, 2020
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.

2 participants