-
-
Notifications
You must be signed in to change notification settings - Fork 11k
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
Update types check #3342
Update types check #3342
Conversation
update isFormdata,isArrayBuffer and isURLSearchParams, because value and Formdata(ArrayBuffer or URLSearchParams) are not the same Window sometimes.
@jasonsaayman hi, when do you plan to release this change? I have a problem with this change. |
update isFormdata,isArrayBuffer and isURLSearchParams, because value and Formdata(ArrayBuffer or URLSearchParams) are not the same Window sometimes. Co-authored-by: Jay <jasonsaayman@gmail.com>
@@ -54,7 +54,7 @@ function isArrayBuffer(val) { | |||
* @returns {boolean} True if value is an FormData, otherwise false | |||
*/ | |||
function isFormData(val) { | |||
return (typeof FormData !== 'undefined') && (val instanceof FormData); | |||
return toString.call(val) === '[object FormData]'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The result of toString.call(val)
in my React Native project returns [object Object]
rather than [object FormData]
which makes file upload fail with this change. See #4412
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This issue seems related too: form-data/form-data#396
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString#using_tostring_to_detect_object_class using this way to detect object class is unreliable, so maybe it shouldn't be used?
update isFormdata,isArrayBuffer and isURLSearchParams, because value and Formdata(ArrayBuffer or URLSearchParams) are not in the same Window sometimes, such as iframe.