| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 915e3e2 commit d5be94e
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -337,9 +337,9 @@ class URLSearchParams { | |||
| 337 | 337 | constructor(init = undefined) { | |
| 338 | 338 | markTransferMode(this, false, false); | |
| 339 | 339 | ||
| 340 | - if (init == null) { | ||
| 340 | + if (init === undefined) { | ||
| 341 | 341 | // Do nothing | |
| 342 | - } else if (typeof init === 'object' || typeof init === 'function') { | ||
| 342 | + } else if (init !== null && (typeof init === 'object' || typeof init === 'function')) { | ||
| 343 | 343 | const method = init[SymbolIterator]; | |
| 344 | 344 | if (method === this[SymbolIterator] && #searchParams in init) { | |
| 345 | 345 | // While the spec does not have this branch, we can use it as a | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,8 +28,14 @@ function makeIterableFunc(array) { | |||
| 28 | 28 | let params; | |
| 29 | 29 | params = new URLSearchParams(undefined); | |
| 30 | 30 | assert.strictEqual(params.toString(), ''); | |
| 31 | + // Per WebIDL union resolution, null is coerced to the USVString "null". | ||
| 32 | + // Refs: https://url.spec.whatwg.org/#interface-urlsearchparams | ||
| 31 | 33 | params = new URLSearchParams(null); | |
| 32 | - assert.strictEqual(params.toString(), ''); | ||
| 34 | + assert.strictEqual(params.toString(), 'null='); | ||
| 35 | + params = new URLSearchParams(false); | ||
| 36 | + assert.strictEqual(params.toString(), 'false='); | ||
| 37 | + params = new URLSearchParams(0); | ||
| 38 | + assert.strictEqual(params.toString(), '0='); | ||
| 33 | 39 | params = new URLSearchParams( | |
| 34 | 40 | makeIterableFunc([['key', 'val'], ['key2', 'val2']]) | |
| 35 | 41 | ); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments