Skip to content
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: handle null in set data #896

Merged
merged 2 commits into from Aug 4, 2018
Merged

Conversation

eddyerburgh
Copy link
Member

  • Handle data set from null to an object

Closes #888

const targetVal = target[key]

if (isPlainObject(val) && isPlainObject(targetVal)) {
recursivelySetData(vm, targetVal, val)
Copy link
Member

Choose a reason for hiding this comment

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

It seems like you just add a check to see if targetVal is a plain object, why does this solve the problem?

Copy link
Member Author

Choose a reason for hiding this comment

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

null isn't a plain object, so we call Vue.set on the target property, rather than recursively setting.

@eddyerburgh eddyerburgh merged commit 44c4520 into vuejs:dev Aug 4, 2018
@eddyerburgh eddyerburgh deleted the fix-set-data branch August 4, 2018 13:12
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.

None yet

2 participants