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

Fixed calling getPrototypeOf(null) #155

Merged
merged 3 commits into from
Jan 18, 2022

Conversation

Cerberus
Copy link
Contributor

I tried to make a simple solution to fix #154.

Copy link
Contributor

@mrbbot mrbbot left a comment

Choose a reason for hiding this comment

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

Thank you very much for the PR! 😃 Looks like this is because even though Type(null) is Null, typeof null is "object": https://tc39.es/ecma262/multipage/ecmascript-language-expressions.html#table-typeof-operator-results, oops. 🙃

Would you be able to move the === null check to just under 3. If Type(O) is not Object..., so it follows the spec?

  if (typeof O !== "object" && typeof O !== "function") return false;
+ if (O === null) return false;

I think we can use === instead of == here as typeof undefined is actually "undefined", so will fail the first check.

@mrbbot mrbbot linked an issue Jan 18, 2022 that may be closed by this pull request
@Cerberus Cerberus requested a review from mrbbot January 18, 2022 13:37
@mrbbot mrbbot merged commit d93200a into cloudflare:master Jan 18, 2022
@mrbbot
Copy link
Contributor

mrbbot commented Jan 18, 2022

Awesome! Thank you! 🎉

@Cerberus Cerberus deleted the fix-getPrototypeOf-null branch January 18, 2022 15:26
@mrbbot
Copy link
Contributor

mrbbot commented Jan 18, 2022

Hey! 👋 I've just released version 2.2.0 including this fix. You can find the full changelog here.

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.

ordinaryHasInstance throws Cannot convert undefined or null to object Error with react-fontawesome
2 participants