Skip to content

Optimize isPlainObject #3120

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

Closed
wants to merge 1 commit into from
Closed

Optimize isPlainObject #3120

wants to merge 1 commit into from

Conversation

hfuuss
Copy link

@hfuuss hfuuss commented Sep 4, 2018

When I saw the isPlainObject function, I found it could be optimized. And did some related tests.

@markerikson
Copy link
Contributor

@timdorr , can we get some clarification on what the specific point of the while loop is? I'm sure you had a good reason for putting it there.

Prior discussion / origination: #2599 .

@markerikson
Copy link
Contributor

Looks like the specific comment is #2599 (comment) :

Just so others understand its purpose: It handles cross-realm objects by walking up the prototype chain until it reaches Object and checks if that "Object" has the same prototype as our potential plain object.

In the case of something coming from an iframe, that Object is different than your own local Object because they come from two different JavaScript contexts. So, we use this technique to get to that definition of Object for the object instance.

Based on that, I think we want to leave it as-is. Closing.

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