diff --git a/packages/core/globals/index.ts b/packages/core/globals/index.ts index acd67edab..5b5ee54d5 100644 --- a/packages/core/globals/index.ts +++ b/packages/core/globals/index.ts @@ -314,7 +314,10 @@ export function initGlobal() { // installPolyfills('text', ['TextDecoder', 'TextEncoder']); // global.registerModule('xhr', () => require('../xhr')); - // installPolyfills('xhr', ['XMLHttpRequest', 'FormData', 'Blob', 'File', 'FileReader']); + // installPolyfills('xhr', ['XMLHttpRequest', 'Blob', 'File', 'FileReader']); + + // global.registerModule('formdata', () => require('../polyfills/formdata')); + // installPolyfills('formdata', ['FormData']); // global.registerModule('fetch', () => require('../fetch')); // installPolyfills('fetch', ['fetch', 'Headers', 'Request', 'Response']); diff --git a/packages/core/polyfills/formdata.ts b/packages/core/polyfills/formdata.ts new file mode 100644 index 000000000..a821dccab --- /dev/null +++ b/packages/core/polyfills/formdata.ts @@ -0,0 +1,22 @@ + +export class FormData { + private _data: Map; + + constructor() { + this._data = new Map(); + } + + append(name: string, value: any) { + this._data.set(name, value); + } + + toString(): string { + const arr = new Array(); + + this._data.forEach(function (value, name, map) { + arr.push(`${encodeURIComponent(name)}=${encodeURIComponent(value)}`); + }); + + return arr.join('&'); + } +} \ No newline at end of file diff --git a/packages/core/xhr/index.ts b/packages/core/xhr/index.ts index 848409703..30a76b204 100644 --- a/packages/core/xhr/index.ts +++ b/packages/core/xhr/index.ts @@ -353,28 +353,6 @@ const statuses = { 505: 'HTTP Version Not Supported', }; -export class FormData { - private _data: Map; - - constructor() { - this._data = new Map(); - } - - append(name: string, value: any) { - this._data.set(name, value); - } - - toString(): string { - const arr = new Array(); - - this._data.forEach(function (value, name, map) { - arr.push(`${encodeURIComponent(name)}=${encodeURIComponent(value)}`); - }); - - return arr.join('&'); - } -} - export class Blob { // Note: only for use by XHR public static InternalAccessor = class {