-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX] Do not eagerly consume modifier args during destruction
Currently, in the 3.13 modifier capabilities version, we eagerly consume the arguments that are passed to the modifier when it is destroying. This can cause issues with backtracking rerender when the state isn't actually used, and neither is the consumption. This change makes it so that we don't eagerly consume these arguments during destruction in general.
- Loading branch information
Chris Garrett
committed
Feb 23, 2021
1 parent
ddb199a
commit 77a0d33
Showing
4 changed files
with
51 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -234,6 +234,52 @@ abstract class ModifierManagerTest extends RenderTest { | |
/You attempted to update `foo` on `.*`, but it had already been used previously in the same computation/ | ||
); | ||
} | ||
|
||
@test | ||
'does not eagerly access arguments during destruction'(assert: Assert) { | ||
class Foo extends CustomModifier {} | ||
|
||
let foo = this.defineModifier(Foo); | ||
|
||
let Main = defineComponent( | ||
{ foo }, | ||
'{{#if @state.show}}<h1 {{foo @state.bar [email protected]}}>hello world</h1>{{/if}}' | ||
); | ||
|
||
let barCount = 0; | ||
let bazCount = 0; | ||
|
||
class State { | ||
@tracked show = true; | ||
|
||
get bar() { | ||
if (this.show === false) { | ||
barCount++; | ||
} | ||
|
||
return; | ||
} | ||
|
||
get baz() { | ||
if (this.show === false) { | ||
bazCount++; | ||
} | ||
|
||
return; | ||
} | ||
} | ||
|
||
let state = new State(); | ||
|
||
this.renderComponent(Main, { state }); | ||
|
||
state.show = false; | ||
|
||
this.rerender(); | ||
|
||
assert.equal(barCount, 0, 'bar was not accessed during detruction'); | ||
assert.equal(bazCount, 0, 'baz was not accessed during detruction'); | ||
} | ||
} | ||
|
||
class ModifierManagerTest313 extends ModifierManagerTest { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters