(reference: any)
| 908 | > = new WeakMap(); |
| 909 | |
| 910 | function encodeFormData(reference: any): Thenable<FormData> { |
| 911 | let resolve, reject; |
| 912 | class="cm">// We need to have a handle on the thenable so that we can synchronously set |
| 913 | class="cm">// its status from processReply, when it can complete synchronously. |
| 914 | const thenable: Thenable<FormData> = new Promise((res, rej) => { |
| 915 | resolve = res; |
| 916 | reject = rej; |
| 917 | }); |
| 918 | processReply( |
| 919 | reference, |
| 920 | class="st">'', |
| 921 | undefined, class="cm">// TODO: This means React Elements can't be used as state in progressive enhancement. |
| 922 | (body: string | FormData) => { |
| 923 | if (typeof body === class="st">'string') { |
| 924 | const data = new FormData(); |
| 925 | data.append(class="st">'0', body); |
| 926 | body = data; |
| 927 | } |
| 928 | const fulfilled: FulfilledThenable<FormData> = (thenable: any); |
| 929 | fulfilled.status = class="st">'fulfilled'; |
| 930 | fulfilled.value = body; |
| 931 | resolve(body); |
| 932 | }, |
| 933 | e => { |
| 934 | const rejected: RejectedThenable<FormData> = (thenable: any); |
| 935 | rejected.status = class="st">'rejected'; |
| 936 | rejected.reason = e; |
| 937 | reject(e); |
| 938 | }, |
| 939 | ); |
| 940 | return thenable; |
| 941 | } |
| 942 | |
| 943 | function defaultEncodeFormAction( |
| 944 | this: any => Promise<any>, |
no test coverage detected