Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Simplify `isPlainObject` #497

Closed
kitcambridge opened this Issue · 2 comments

2 participants

@kitcambridge

Since we can leverage __proto__ without worrying about compatibility issues, I think we can reduce isPlainObject to the following:

function isPlainObject(value) {
  return value && toString.call(value) == "[object Object]" && value.__proto__ == Object.prototype
}

What do you think?

@madrobby
Owner

Unit tests fail with:

ZeptoTest#testIsPlainObject: null is not plain object Expected null to be false.
@kitcambridge

Whoops...passing in null returns null instead of false. This should work:

function isPlainObject(value) {
  return !!(value && toString.call(value) == "[object Object]" && value.__proto__ == Object.prototype)
}
@madrobby madrobby closed this in a066635
@lopper lopper referenced this issue from a commit in buddydvd/zepto
@kitcambridge kitcambridge Simplify `isPlainObject`. Closes #497. a180955
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.