Closed
Conversation
Signed-off-by: Matteo Collina <hello@matteocollina.com>
tsctx
reviewed
Nov 19, 2024
| // Set source to a copy of the bytes held by object. | ||
| source = new Uint8Array(object.buffer.slice(object.byteOffset, object.byteOffset + object.byteLength)) | ||
| } else if (webidl.is.FormData(object)) { | ||
| } else if (webidl.is.FormData(object) || (globalThis.FormData && object instanceof FormData)) { |
Member
There was a problem hiding this comment.
Suggested change
| } else if (webidl.is.FormData(object) || (globalThis.FormData && object instanceof FormData)) { | |
| } else if (webidl.is.FormData(object)) { |
|
|
||
| webidl.is.FormData = webidl.util.MakeTypeAssertion(FormData) | ||
| const _isFormData = webidl.util.MakeTypeAssertion(FormData) | ||
| webidl.is.FormData = function (V) { |
Member
There was a problem hiding this comment.
How about something like this?
// lib/web/fetch/webidl.js
webidl.util.MakeTypeAssertionMultiple = function (List) {
return (O) => List.some((I) => FunctionPrototypeSymbolHasInstance(I, O))
}Usage:
webidl.is.FormData = webidl.util.MakeTypeAssertionMultiple([FormData, gloablThis.FormData].filter(Boolean))
Member
|
I don't understand the need for this change, it's a known limitation that different versions of undici create different versions of classes. It's also a pain to deal with. Won't work: new Request(new globalThis.Request('http://a'))
await fetch(new globalThis.Request(...))Works because of webidl:
|
Member
Author
|
Ok, let's close this. We would need to document this a bit better, as I suspect a flurry of issues. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since #3502, we only support our own classes, and that is the right move. However, we need to relax this condition to allow for
globalThis.FormData, as that is a different copy of undici.In essence, this change make the following fork