[BUGFIX release] Backport autotracking bugfixes#18721
Merged
Conversation
rwjblue
requested changes
Feb 1, 2020
added 3 commits
February 3, 2020 10:42
Previously, the arg proxy used a custom system for passing along its `capturedArgs` directly to `getChainTags`, in order to interoperate with computed properties. As it turns out, there are a number of other places where the correct tag needs to be gotten and setup. This PR replaces the `UNKNOWN_PROPERTY_TAG` system with a more general `CUSTOM_TAG_FOR` system. In this system, if we detect that an object has this method, we defer to it to get the tag, even if the property was defined on the object. There are two users of this system: - ProxyMixin - The arg proxy Given that it's private, and we have relatively few use cases, I believe this is the cleanest solution at the moment. The alternative would be to keep `UNKNOWN_PROPERTY_TAG` and also add `CUSTOM_TAG_FOR`, but that seems unnecessary given low usage.
Currently, the Proxy mixin uses the private `UNKNOWN_PROPERTY_TAG` API to provide the tags for the content property that the mixin is proxying to. However, previously the chains system would do this _and_ still entangle changes to the local property. This allowed users to manually notify in subclasses of Proxy. This PR adds the tag for the property back to the returned tag, so it works the same as before. It also refactors `setupMandatorySetter`, since we now have to do that work in two places (to avoid re-entry).
Currently, if `arrangedContent` is overridden in an ArrayProxy with a
computed property that depends on changes to another array/context,
those changes will not propagate correctly. This is because we never
link the tags of the ArrayProxy to the corresponding tags of the
`arrangedContent`, instead relying on array observers to propagate
changes. This works when the underlying array is being changed directly,
but _doesn't_ work if the array is being replaced entirely (e.g. the
computed property has invalidated and needs to recompute).
This PR ensures that ArrayProxy tags are setup correctly, so that if
`arrangedContent` ever changes, the proxy will also propagate those
changes. This will affect anything that depends on the ArrayProxy
directly, such as `{{#each}}` loops and other computed properties.
One side effect of this is that ArrayProxy's no longer need to manually
dirty themselves, and in fact attempting to do so can trigger the
backtracking rerender assertion (specifically when the proxy first
attempts to update/synchronize while rendering). Internally, a boolean
flag has been added to the array change methods to allow it to opt-out
of sending a notification.
7f9edd7 to
63f9f45
Compare
rwjblue
approved these changes
Feb 3, 2020
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.