Skip to content

Handle non-reactive nulls (#231) #241

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

Merged
merged 8 commits into from
Jun 10, 2020
Merged

Handle non-reactive nulls (#231) #241

merged 8 commits into from
Jun 10, 2020

Conversation

coolhome
Copy link
Contributor

@coolhome coolhome commented Jan 31, 2020

Fix for #231 - Ensure non reactive nulls are supported.

// 'this' cannot be set to null.
Object.hasOwnProperty.call(null, ''); // TypeError Cannot convert undefined or null to object

// Not an Object...
(null).hasOwnProperty('') // TypeError: Cannot read property 'hasOwnProperty' of null

Solution would be to check if the obj is null.

@coolhome coolhome changed the title Handle non-reactive nulls Handle non-reactive nulls (#231) Jan 31, 2020
@coolhome coolhome requested a review from liximomo January 31, 2020 03:00
src/utils.ts Outdated
export function hasOwn(obj: Object | any[], key: string): boolean {
return hasOwnProperty.call(obj, key);
return obj !== null && Object.hasOwnProperty.call(obj, key);
Copy link
Member

@haoqunjiang haoqunjiang Feb 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better do the obj !== null test in the isReactive function.
And change the obj: Object to obj: object, to make the code clearer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sodatea thanks for the feedback!

@coolhome coolhome requested a review from haoqunjiang February 20, 2020 04:07
@coolhome coolhome requested review from haoqunjiang and removed request for haoqunjiang February 20, 2020 13:27
@antfu antfu self-assigned this Jun 2, 2020
@antfu antfu mentioned this pull request Jun 3, 2020
@antfu
Copy link
Member

antfu commented Jun 9, 2020

This is covered by #311 and no longer an issue in v0.6.1. However, I think we can take the unit-tests.

@antfu antfu merged commit 34c0fad into vuejs:master Jun 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants