GeezerVison is showing github.com — lib: add FormData global when fetch is enabled · nodejs/node@ec0d623
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .eslintrc.js +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -319,6 +319,7 @@ module.exports = { | 319 | 319 | Crypto: 'readable', | 320 | 320 | CryptoKey: 'readable', | 321 | 321 | fetch: 'readable', | | 322 | + FormData: 'readable', | 322 | 323 | globalThis: 'readable', | 323 | 324 | Response: 'readable', | 324 | 325 | SubtleCrypto: 'readable', | |
Collapse file Copy file name to clipboardExpand all lines: doc/api/globals.md +11Lines changed: 11 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -363,6 +363,17 @@ added: v17.5.0 | 363 | 363 |
| 364 | 364 | A browser-compatible implementation of the [`fetch()`][] function. | 365 | 365 |
| | 366 | +## Class `FormData` | | 367 | + | | 368 | +<!-- YAML | | 369 | +added: REPLACEME | | 370 | +--> | | 371 | + | | 372 | +> Stability: 1 - Experimental. Enable this API with the [`--experimental-fetch`][] | | 373 | +> CLI flag. | | 374 | +
| | 375 | +A browser-compatible implementation of {FormData}. | | 376 | + | 366 | 377 | ## `global` | 367 | 378 |
| 368 | 379 | <!-- YAML | |
Collapse file Copy file name to clipboardExpand all lines: lib/.eslintrc.yaml +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 47 | 47 | message: Use `const { Event } = require('internal/event_target');` instead of the global. | 48 | 48 | - name: EventTarget | 49 | 49 | message: Use `const { EventTarget } = require('internal/event_target');` instead of the global. | | 50 | + - name: FormData | | 51 | + message: Use `const { FormData } = require('internal/deps/undici/undici');` instead of the global. | 50 | 52 | - name: Headers | 51 | 53 | message: Use `const { Headers } = require('internal/deps/undici/undici');` instead of the global. | 52 | 54 | # Intl is not available in primordials because it can be | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/bootstrap/pre_execution.js +6Lines changed: 6 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -163,6 +163,12 @@ function setupFetch() { | 163 | 163 | configurable: true, | 164 | 164 | value: undici.fetch | 165 | 165 | }); | | 166 | + ObjectDefineProperty(globalThis, 'FormData', { | | 167 | + writable: true, | | 168 | + enumerable: false, | | 169 | + configurable: true, | | 170 | + value: undici.FormData | | 171 | + }); | 166 | 172 | ObjectDefineProperty(globalThis, 'Headers', { | 167 | 173 | writable: true, | 168 | 174 | enumerable: false, | |
Collapse file Copy file name to clipboardExpand all lines: test/common/index.js +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -303,6 +303,7 @@ if (global.structuredClone) { | 303 | 303 | if (global.fetch) { | 304 | 304 | knownGlobals.push( | 305 | 305 | global.fetch, | | 306 | + global.FormData, | 306 | 307 | global.Request, | 307 | 308 | global.Response, | 308 | 309 | global.Headers, | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-fetch.mjs +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -7,6 +7,7 @@ import events from 'events'; | 7 | 7 | import http from 'http'; | 8 | 8 |
| 9 | 9 | assert.strictEqual(typeof globalThis.fetch, 'function'); | | 10 | +assert.strictEqual(typeof globalThis.FormData, 'function'); | 10 | 11 | assert.strictEqual(typeof globalThis.Headers, 'function'); | 11 | 12 | assert.strictEqual(typeof globalThis.Request, 'function'); | 12 | 13 | assert.strictEqual(typeof globalThis.Response, 'function'); | |
Collapse file Copy file name to clipboardExpand all lines: test/wpt/test-url.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -11,7 +11,7 @@ runner.setScriptModifier((obj) => { | 11 | 11 | // created via `document.createElement`. So we need to ignore them and just | 12 | 12 | // test `URL`. | 13 | 13 | obj.code = obj.code.replace(/\["url", "a", "area"\]/, '[ "url" ]'); | 14 | | - } else if (typeof FormData === 'undefined' && // eslint-disable-line | | 14 | + } else if (typeof FormData === 'undefined' && | 15 | 15 | obj.filename.includes('urlsearchparams-constructor.any.js')) { | 16 | 16 | // TODO(XadillaX): Remove this `else if` after `FormData` is supported. | 17 | 17 |
| |
Collapse file Copy file name to clipboardExpand all lines: tools/doc/type-parser.mjs +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -271,6 +271,7 @@ const customTypesMap = { | 271 | 271 | 'TextDecoderStream': | 272 | 272 | 'webstreams.md#class-textdecoderstream', | 273 | 273 |
| | 274 | + 'FormData': 'https://developer.mozilla.org/en-US/docs/Web/API/FormData', | 274 | 275 | 'Headers': 'https://developer.mozilla.org/en-US/docs/Web/API/Headers', | 275 | 276 | 'Response': 'https://developer.mozilla.org/en-US/docs/Web/API/Response', | 276 | 277 | 'Request': 'https://developer.mozilla.org/en-US/docs/Web/API/Request', | |
|