glimmerjs / glimmer-vm

MIT License
1.13k stars 191 forks source link

Don't infinitely duplicate positional arguments when modifiers update #1565

Closed NullVoxPopuli closed 8 months ago

NullVoxPopuli commented 9 months ago

:see_no_evil:

Paired with @chancancode on this

This bug was found accidentally while trying to figure out a glimmer-repro for:

NullVoxPopuli commented 9 months ago

Atm, this test is failing:

  @test
  'Can pass curried modifier as argument and invoke dynamically (with named args, multi-layer)'() {
    const foo = defineSimpleModifier(
      (element: Element, _: unknown, { greeting, name }: { greeting: string; name: string }) =>
        (element.innerHTML = `${greeting} ${name}`)
    );

    this.registerComponent('TemplateOnly', 'Foo', '<div {{@value name="Nebula!"}}></div>');
    this.registerComponent(
      'TemplateOnly',
      'Bar',
      '<Foo @value={{modifier @value greeting="Hello," name="world!"}}/>'
    );

    this.render('<Bar @value={{modifier this.foo greeting="Hola,"}}/>', { foo });
    this.assertHTML('<div>Hello, Nebula!</div>');
    this.assertStableRerender();
  }