Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Bring back default parameter
  • Loading branch information
TimothyGu authored Jan 30, 2017
commit 28130631bd09aaf7988adcdf1b5b5e7031e15c5a
6 changes: 5 additions & 1 deletion 6 lib/internal/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,11 @@ function getObjectFromParams(array) {
}

class URLSearchParams {
constructor(init) {
// URL Standard says the default value is '', but as undefined and '' have
// the same result, undefined is used to prevent unnecessary parsing.
// Default parameter is necessary to keep URLSearchParams.length === 0 in
// accordance with Web IDL spec.
constructor(init = undefined) {
if (init === null || init === undefined) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have init = '' as default then init can't be undefined?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The user can do new URLSearchParams(undefined). The default is there to echo the = "" in the spec, though now I agree it's a bit pointless.

this[searchParams] = [];
} else if (typeof init === 'object') {
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.