summaryrefslogtreecommitdiff
path: root/ext/fetch/21_formdata.js
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2022-01-27 16:27:22 +0100
committerGitHub <noreply@github.com>2022-01-27 16:27:22 +0100
commitf248e6f1778dc26db91d3322de2ecca5d1aa9866 (patch)
tree46b1ff59091cc8d31ff67427173d3a0148734007 /ext/fetch/21_formdata.js
parent382a978859a7a7a4351542be818bb2e59523429c (diff)
Revert "refactor: update runtime code for primordial checks for "instanceof" (#13497)" (#13511)
This reverts commit 884143218fad0e18f7553aaf079d52de703f7601.
Diffstat (limited to 'ext/fetch/21_formdata.js')
-rw-r--r--ext/fetch/21_formdata.js34
1 files changed, 12 insertions, 22 deletions
diff --git a/ext/fetch/21_formdata.js b/ext/fetch/21_formdata.js
index a134fe5f7..cc338de72 100644
--- a/ext/fetch/21_formdata.js
+++ b/ext/fetch/21_formdata.js
@@ -13,8 +13,7 @@
((window) => {
const core = window.Deno.core;
const webidl = globalThis.__bootstrap.webidl;
- const { Blob, BlobPrototype, File, FilePrototype } =
- globalThis.__bootstrap.file;
+ const { Blob, File } = globalThis.__bootstrap.file;
const {
ArrayPrototypeMap,
ArrayPrototypePush,
@@ -26,7 +25,6 @@
MapPrototypeGet,
MapPrototypeSet,
MathRandom,
- ObjectPrototypeIsPrototypeOf,
Symbol,
StringFromCharCode,
StringPrototypeTrim,
@@ -50,16 +48,10 @@
* @returns {FormDataEntry}
*/
function createEntry(name, value, filename) {
- if (
- ObjectPrototypeIsPrototypeOf(BlobPrototype, value) &&
- !ObjectPrototypeIsPrototypeOf(FilePrototype, value)
- ) {
+ if (value instanceof Blob && !(value instanceof File)) {
value = new File([value], "blob", { type: value.type });
}
- if (
- ObjectPrototypeIsPrototypeOf(FilePrototype, value) &&
- filename !== undefined
- ) {
+ if (value instanceof File && filename !== undefined) {
value = new File([value], filename, {
type: value.type,
lastModified: value.lastModified,
@@ -97,7 +89,7 @@
* @returns {void}
*/
append(name, valueOrBlobValue, filename) {
- webidl.assertBranded(this, FormDataPrototype);
+ webidl.assertBranded(this, FormData);
const prefix = "Failed to execute 'append' on 'FormData'";
webidl.requiredArguments(arguments.length, 2, { prefix });
@@ -105,7 +97,7 @@
prefix,
context: "Argument 1",
});
- if (ObjectPrototypeIsPrototypeOf(BlobPrototype, valueOrBlobValue)) {
+ if (valueOrBlobValue instanceof Blob) {
valueOrBlobValue = webidl.converters["Blob"](valueOrBlobValue, {
prefix,
context: "Argument 2",
@@ -133,7 +125,7 @@
* @returns {void}
*/
delete(name) {
- webidl.assertBranded(this, FormDataPrototype);
+ webidl.assertBranded(this, FormData);
const prefix = "Failed to execute 'name' on 'FormData'";
webidl.requiredArguments(arguments.length, 1, { prefix });
@@ -156,7 +148,7 @@
* @returns {FormDataEntryValue | null}
*/
get(name) {
- webidl.assertBranded(this, FormDataPrototype);
+ webidl.assertBranded(this, FormData);
const prefix = "Failed to execute 'get' on 'FormData'";
webidl.requiredArguments(arguments.length, 1, { prefix });
@@ -176,7 +168,7 @@
* @returns {FormDataEntryValue[]}
*/
getAll(name) {
- webidl.assertBranded(this, FormDataPrototype);
+ webidl.assertBranded(this, FormData);
const prefix = "Failed to execute 'getAll' on 'FormData'";
webidl.requiredArguments(arguments.length, 1, { prefix });
@@ -197,7 +189,7 @@
* @returns {boolean}
*/
has(name) {
- webidl.assertBranded(this, FormDataPrototype);
+ webidl.assertBranded(this, FormData);
const prefix = "Failed to execute 'has' on 'FormData'";
webidl.requiredArguments(arguments.length, 1, { prefix });
@@ -219,7 +211,7 @@
* @returns {void}
*/
set(name, valueOrBlobValue, filename) {
- webidl.assertBranded(this, FormDataPrototype);
+ webidl.assertBranded(this, FormData);
const prefix = "Failed to execute 'set' on 'FormData'";
webidl.requiredArguments(arguments.length, 2, { prefix });
@@ -227,7 +219,7 @@
prefix,
context: "Argument 1",
});
- if (ObjectPrototypeIsPrototypeOf(BlobPrototype, valueOrBlobValue)) {
+ if (valueOrBlobValue instanceof Blob) {
valueOrBlobValue = webidl.converters["Blob"](valueOrBlobValue, {
prefix,
context: "Argument 2",
@@ -269,7 +261,6 @@
webidl.mixinPairIterable("FormData", FormData, entryList, "name", "value");
webidl.configurePrototype(FormData);
- const FormDataPrototype = FormData.prototype;
const escape = (str, isFilename) =>
StringPrototypeReplace(
@@ -500,11 +491,10 @@
}
webidl.converters["FormData"] = webidl
- .createInterfaceConverter("FormData", FormDataPrototype);
+ .createInterfaceConverter("FormData", FormData);
globalThis.__bootstrap.formData = {
FormData,
- FormDataPrototype,
formDataToBlob,
parseFormData,
formDataFromEntries,