Skip to content

Occurred TypeError in Observer.create #1765

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 2 commits into from
Nov 9, 2015
Merged

Conversation

kazupon
Copy link
Member

@kazupon kazupon commented Nov 8, 2015

I create the object with Object.create(null) for plugin, and when it would try to define as reactivity object with Vue.util.defineReactive, occured the TypeError in Observer.create.

Please see the following jsfiddle:
https://jsfiddle.net/kazupon/yo2cmsLp/1/

In Vue.js, Can I define the reactity object was created with Object.create(null) ?

If this is bug, I hope that you will check PR.

@@ -47,7 +47,7 @@ Observer.create = function (value, vm) {
}
var ob
if (
value.hasOwnProperty('__ob__') &&
'__ob__' in value &&
Copy link
Member

Choose a reason for hiding this comment

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

Thanks, but using in operator this would return true if the __ob__ is defined on the prototype as well. We can use Object.prototype.hasOwnProperty.call(value, '__ob__').

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks!
You're right.

@kazupon
Copy link
Member Author

kazupon commented Nov 9, 2015

I fixed. 😸

yyx990803 added a commit that referenced this pull request Nov 9, 2015
Occurred TypeError in Observer.create
@yyx990803 yyx990803 merged commit 0a76d21 into vuejs:dev Nov 9, 2015
@yyx990803
Copy link
Member

Thanks!

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.

2 participants