-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛Fix bind data when start and end are the same #21566
Conversation
|
||
/** @const */ | ||
this['end'] = dates[dates.length - 1]; | ||
this['end'] = map(dates[dates.length - 1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we verify that dates.length > 0
anywhere? Also, why did the original cause a circular reference error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For your first question, getBindDates_
always takes at least one date, so the array will always have length 1 as currently written. But it could be good defensive programming practice to add a dev assert.
For your second question, when Bind attempts to deepMerge
the new state with the old state, the deepMerge
function marks objects in the new state as seen
as it iterates through the state tree. If there is an object reference assigned to 2 properties of the new state object, it gets marked as seen and is encountered again, emitting the error. Not sure if this is WAI, but it's easy to work around.
Lines 105 to 107 in 391a431
if (seen.includes(s)) { | |
throw new Error('Source object has a circular reference.'); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Thanks for the clarifications!
Thanks for the review!! |
* Fix bind data when start and end are the same * Use standard for loop instead to avoid complexity * Fix circular reference error from bind * Use isSameOrAfter * Fix missing externs
Fixes #20727