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

fix: symbol.hasInstance needed to be static #136

Merged
merged 1 commit into from
Sep 29, 2021
Merged

Conversation

jimmywarting
Copy link
Owner

The purpose of this PR is:

... the symbol.hasInstance didn't work cuz it wasn't static


@jimmywarting jimmywarting merged commit 36e2491 into master Sep 29, 2021
@jimmywarting jimmywarting deleted the fix-hasInstance branch September 29, 2021 21:47
@github-actions
Copy link

🎉 This PR is included in version 4.0.9 🎉

The release is available on:

Your semantic-release bot 📦🚀

@@ -18,7 +18,7 @@ export const FormData = class FormData {
constructor(...a){if(a.length)throw new TypeError(`Failed to construct 'FormData': parameter 1 is not of type 'HTMLFormElement'.`)}
get [t]() {return 'FormData'}
[i](){return this.entries()}
[h](o) {return typeof o==='object'&&o[t]==='FormData'&&!m.some(m=>typeof o[m]!='function')}
static [h](o) {return typeof o==='object'&&o[t]==='FormData'&&!m.some(m=>typeof o[m]!='function')}
Copy link

@octet-stream octet-stream Sep 30, 2021

Choose a reason for hiding this comment

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

typeof object === "object" && object[Symbol.toStringTag] === "FormData"

This assertion will cause an error when object is null, same issue as node-fetch/fetch-blob#58
I also think that you'll better check at least some methods existence. I think these assertions would be more than enough: https://github.com/octet-stream/form-data-encoder/blob/a94e5e4c37304334349b902d094048e380ff6ab2/lib/util/isFormData.ts#L10-L18

Copy link
Owner Author

Choose a reason for hiding this comment

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

Thx, fixed

@jimmywarting jimmywarting mentioned this pull request Sep 30, 2021
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants