-
Notifications
You must be signed in to change notification settings - Fork 1
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
[1.x] Fix reactivity conflict caused by Object.prototype.hasOwnProperty #35
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -213,9 +213,6 @@ type PathValueEntry<T, P extends PathEntry<T, Depth>, Depth extends number = 10> | |||||||||||
type SafeObject = Record<string, unknown> | ||||||||||||
type SearchableObject = object | ||||||||||||
|
||||||||||||
// eslint-disable-next-line @typescript-eslint/unbound-method | ||||||||||||
const hasOwnProperty = Object.prototype.hasOwnProperty | ||||||||||||
|
||||||||||||
/** | ||||||||||||
* Retrieves a value from an object by dot notation. The value is received by optional chaining, | ||||||||||||
* therefore this function returns undefined if an intermediate property is undefined. | ||||||||||||
|
@@ -238,8 +235,8 @@ function getByPath<T extends SearchableObject, P extends PathEntry<T> & string>( | |||||||||||
return pathArray.reduce((current: unknown, pathPart) => { | ||||||||||||
if ( | ||||||||||||
typeof current !== 'object' || | ||||||||||||
current === null || | ||||||||||||
!hasOwnProperty.call(current, pathPart) | ||||||||||||
// eslint-disable-next-line no-prototype-builtins | ||||||||||||
!current?.hasOwnProperty(pathPart) // We use the builtin to avoid reactivity issues with Proxy | ||||||||||||
) { | ||||||||||||
return undefined | ||||||||||||
} | ||||||||||||
|
@@ -283,8 +280,8 @@ function setByPath< | |||||||||||
const parentObject = pathArray.reduce<unknown>((current, pathPart) => { | ||||||||||||
if ( | ||||||||||||
typeof current !== 'object' || | ||||||||||||
current === null || | ||||||||||||
!hasOwnProperty.call(current, pathPart) | ||||||||||||
// eslint-disable-next-line no-prototype-builtins | ||||||||||||
!current?.hasOwnProperty(pathPart) | ||||||||||||
Comment on lines
+283
to
+284
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
The same here. Adding this undefined check should not change behavior, since the check in line 292 would have catched the undefined There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like a good alternative, I see that you already released it, so I will close this |
||||||||||||
) { | ||||||||||||
throwAssignmentError(current, pathPart) | ||||||||||||
} | ||||||||||||
|
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.
I would suggest this. We still use the global
hasOwnProperty
function but signal vue, that we access the property so its depedency tracking works.