-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Faster/simpler isPlainObject check #3483
Conversation
This runs up the prototype chain to check equivalency. When run in a cross-realm environment (differing contexts, iframes, etc), this ensures we're checking the value's prototype matches its context-specific instance of Object. This is faster than calling `toString()` on the constructor. There's still the `baseGetTag()` call, which does its own `toString()`, but this swaps out one for cross-realm stuff. It's also a bit simpler to understand, I think.
Do I need to do anything to get the tests to run? I checked out the |
Awesome! Thank you! That's fine for now. I think we can even remove some of the |
I had some difficulty there. These two tests fail in that case:
There's some edge case handling in #2705, but that's a good issue to read through for a reminder of why this check exists. It does feel a little weird to be looking to toString() to answer the question. I'm not sure if there's a workaround, but with all these new reflective APIs to override the toString() output, it's definitely a complex problem. |
Cool. I'll re-evaluate those checks for v5. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This runs up the prototype chain to check equivalency. When run in a cross-realm environment (differing contexts, iframes, etc), this ensures we're checking the value's prototype matches its context-specific instance of Object.
This is faster than calling
toString()
on the constructor. There's still thebaseGetTag()
call, which does its owntoString()
, but this swaps out one for cross-realm stuff. It's also a bit simpler to understand, I think.