-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add
value
argument of URLSearchParams.prototype.{ has, delete }
- Loading branch information
Showing
14 changed files
with
170 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
'use strict'; | ||
var getBuiltIn = require('../internals/get-built-in'); | ||
var defineBuiltIn = require('../internals/define-built-in'); | ||
var uncurryThis = require('../internals/function-uncurry-this'); | ||
var toString = require('../internals/to-string'); | ||
var validateArgumentsLength = require('../internals/validate-arguments-length'); | ||
|
||
var URLSearchParams = getBuiltIn('URLSearchParams'); | ||
var URLSearchParamsPrototype = URLSearchParams.prototype; | ||
var append = uncurryThis(URLSearchParamsPrototype.append); | ||
var $delete = uncurryThis(URLSearchParamsPrototype['delete']); | ||
var forEach = uncurryThis(URLSearchParamsPrototype.forEach); | ||
var has = uncurryThis(URLSearchParamsPrototype.has); | ||
var push = uncurryThis([].push); | ||
var params = new URLSearchParams('a=1&a=2'); | ||
|
||
params['delete']('a', 1); | ||
|
||
if (params + '' !== 'a=2') { | ||
defineBuiltIn(URLSearchParamsPrototype, 'delete', function (name /* , value */) { | ||
has(this, ''); // validate `this` | ||
if (validateArgumentsLength(arguments.length, 1) < 2) return $delete(this, name); | ||
var key = toString(name); | ||
var $value = arguments[1]; | ||
if ($value === undefined) return $delete(this, key); | ||
var value = toString($value); | ||
var entries = []; | ||
forEach(this, function (v, k) { | ||
push(entries, { key: k, value: v }); | ||
}); | ||
var index = 0; | ||
var length = entries.length; | ||
while (index < length) { | ||
$delete(this, entries[index++].key); | ||
} | ||
index = 0; | ||
while (index < length) { | ||
var entry = entries[index++]; | ||
if (!(entry.key === key && entry.value === value)) append(this, entry.key, entry.value); | ||
} | ||
}, { enumerable: true, unsafe: true }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use strict'; | ||
var getBuiltIn = require('../internals/get-built-in'); | ||
var defineBuiltIn = require('../internals/define-built-in'); | ||
var uncurryThis = require('../internals/function-uncurry-this'); | ||
var toString = require('../internals/to-string'); | ||
var validateArgumentsLength = require('../internals/validate-arguments-length'); | ||
|
||
var URLSearchParams = getBuiltIn('URLSearchParams'); | ||
var URLSearchParamsPrototype = URLSearchParams.prototype; | ||
var getAll = uncurryThis(URLSearchParamsPrototype.getAll); | ||
var $has = uncurryThis(URLSearchParamsPrototype.has); | ||
var params = new URLSearchParams('a=1'); | ||
|
||
if (params.has('a', 2)) { | ||
defineBuiltIn(URLSearchParamsPrototype, 'has', function has(name /* , value */) { | ||
$has(this, ''); // validate `this` | ||
if (validateArgumentsLength(arguments.length, 1) < 2) return $has(this, name); | ||
var values = getAll(this, name); | ||
var $value = arguments[1]; | ||
if ($value === undefined) return values.length !== 0; | ||
var value = toString($value); | ||
var index = 0; | ||
while (index < values.length) { | ||
if (values[index++] === value) return true; | ||
} return false; | ||
}, { enumerable: true, unsafe: true }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,2 @@ | ||
// https://github.com/jasnell/proposal-url | ||
require('../modules/web.url'); | ||
require('../modules/web.url.can-parse'); | ||
require('../modules/web.url.to-json'); | ||
require('../modules/web.url-search-params'); | ||
require('../modules/web.url-search-params.size'); | ||
require('../web/url'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
require('./url-search-params'); | ||
require('../modules/web.url'); | ||
require('../modules/web.url.can-parse'); | ||
require('../modules/web.url.to-json'); | ||
require('../modules/web.url-search-params'); | ||
require('../modules/web.url-search-params.size'); | ||
var path = require('../internals/path'); | ||
|
||
module.exports = path.URL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters