-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX] Update iterable items only when changed
Currently, iterable item references always update their value and dirty their tag, even if the value didn't actually change. This is different from the baseline behavior in Ember, and a regression. This PR updates this behavior, and also updates affected tests. These tests were written prior to the recent VM upgrade, and probably assumed some differences in behaviors in the testing environment. Now that we're trying to align the testing environment more closely with Ember, these tests need to be updated. I added a `@tracked` decorator to the test helpers, which should allow us to more closely match Ember's behavior.
- Loading branch information
Chris Garrett
committed
May 15, 2020
1 parent
fea493f
commit 7b6266a
Showing
4 changed files
with
87 additions
and
13 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
15 changes: 15 additions & 0 deletions
15
packages/@glimmer/integration-tests/lib/test-helpers/tracked.ts
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { trackedData } from '@glimmer/validator'; | ||
|
||
export function tracked(target: object, key: string) { | ||
let { getter, setter } = trackedData<any, any>(key); | ||
|
||
Object.defineProperty(target, key, { | ||
get() { | ||
return getter(this); | ||
}, | ||
|
||
set(value: unknown) { | ||
setter(this, value); | ||
}, | ||
}); | ||
} |
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