Skip to content

If in #each block naming collision #1275

@bwbroersma

Description

@bwbroersma

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);
		}
	};
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions