-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX lts] Ensure hash objects correctly entangle as dependencies v2
The previous bugfixes to `{{hash}}` caused a change to the semantics of computed properties that depend on a hash. Specifically, because `{{hash}}` objects are now proxies, they are _constant_, never updating again after they are initially created. This is fine if you depend on an individual key in a hash, but breaks if you depend directly on the hash itself: ```js computed('hash.foo', function() {}) // this works computed('hash', function() {}) // this will no longer rerun ``` This is used occasionally when you wish to depend on the dynamic keys of a dictionary, like so: ```js computed('hash', function() { let values = []; for (let key in this.hash) { values.push(hash[key]); } return values; }) ``` Notably, this is not a problem with autotracking, because autotracking will entangle the usage of these keys dynamically. So this is only a problem with legacy systems such as `computed` and `observer` which cannot dynamically add dependencies based on the function's runtime. To fix this, we need to determine if a dependency is a hash when a computed or an observer depends upon it, and then entangle all of its keys if it is. We do this whenever the value is the last value in the chain.
- Loading branch information
Chris Garrett
committed
Jun 21, 2021
1 parent
b4ace38
commit 03b20d8
Showing
4 changed files
with
174 additions
and
155 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
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
Oops, something went wrong.