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

If in #each block naming collision #1275

Closed
bwbroersma opened this issue Mar 25, 2018 · 2 comments · Fixed by #1312
Closed

If in #each block naming collision #1275

bwbroersma opened this issue Mar 25, 2018 · 2 comments · Fixed by #1312
Labels

Comments

@bwbroersma
Copy link
Contributor

Stuff broke after 1.55.1 for me, I got naming collisions in this case:

{{#each list as nested}}
  {{#if true}}
    <Nested :nested/>
  {{/if}}
{{/each}}
<script>
  import Nested from './Nested.html';
  export default {
    data: () => ({
      list: [1,2]
    }),
    components: {
      Nested
    }
  };
</script>

The output in 1.58.2 is:

// (2:2) {{#if true}}
function create_if_block(component, state) {
	var nested = state.nested, each_value = state.each_value, nested_index = state.nested_index;

	var nested = new Nested({
		root: component.root,
		data: { nested: nested }
	});

	return {
		c: function create() {
			nested._fragment.c();
		},

		m: function mount(target, anchor) {
			nested._mount(target, anchor);
		},

		p: function update(changed, state) {
			nested = state.nested;
			each_value = state.each_value;
			nested_index = state.nested_index;
			var nested_changes = {};
			if (changed.list) nested_changes.nested = nested;
			nested._set(nested_changes);
		},

		u: function unmount() {
			nested._unmount();
		},

		d: function destroy() {
			nested.destroy(false);
		}
	};
}
@bwbroersma
Copy link
Contributor Author

I think

const context = this.block.getUniqueName(this.context);
should be changed to

const context = this.generator.getUniqueName(this.context);

However if I change it I get 3 errors on the runtime deconflict-component-refs test.

@Rich-Harris Rich-Harris added the bug label Apr 4, 2018
Rich-Harris added a commit that referenced this issue Apr 4, 2018
deconflict against inherited contexts
@Rich-Harris
Copy link
Member

Thank you — this is fixed in 1.60.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants