mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
fix: new polyfill for formdata
This commit is contained in:
@@ -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']);
|
||||
|
||||
22
packages/core/polyfills/formdata.ts
Normal file
22
packages/core/polyfills/formdata.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
export class FormData {
|
||||
private _data: Map<string, any>;
|
||||
|
||||
constructor() {
|
||||
this._data = new Map<string, any>();
|
||||
}
|
||||
|
||||
append(name: string, value: any) {
|
||||
this._data.set(name, value);
|
||||
}
|
||||
|
||||
toString(): string {
|
||||
const arr = new Array<string>();
|
||||
|
||||
this._data.forEach(function (value, name, map) {
|
||||
arr.push(`${encodeURIComponent(name)}=${encodeURIComponent(value)}`);
|
||||
});
|
||||
|
||||
return arr.join('&');
|
||||
}
|
||||
}
|
||||
@@ -353,28 +353,6 @@ const statuses = {
|
||||
505: 'HTTP Version Not Supported',
|
||||
};
|
||||
|
||||
export class FormData {
|
||||
private _data: Map<string, any>;
|
||||
|
||||
constructor() {
|
||||
this._data = new Map<string, any>();
|
||||
}
|
||||
|
||||
append(name: string, value: any) {
|
||||
this._data.set(name, value);
|
||||
}
|
||||
|
||||
toString(): string {
|
||||
const arr = new Array<string>();
|
||||
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user