-
-
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
167 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,41 @@ | ||
'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 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 */) { | ||
var length = arguments.length; | ||
var $value = length < 2 ? undefined : arguments[1]; | ||
if (length && $value === undefined) return $delete(this, name); | ||
var entries = []; | ||
forEach(this, function (v, k) { // also validates `this` | ||
push(entries, { key: k, value: v }); | ||
}); | ||
validateArgumentsLength(length, 1); | ||
var key = toString(name); | ||
var value = toString($value); | ||
var index = 0; | ||
var entriesLength = entries.length; | ||
while (index < entriesLength) { | ||
$delete(this, entries[index++].key); | ||
} | ||
index = 0; | ||
while (index < entriesLength) { | ||
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 */) { | ||
var length = arguments.length; | ||
var $value = length < 2 ? undefined : arguments[1]; | ||
if (length && $value === undefined) return $has(this, name); | ||
var values = getAll(this, name); // also validates `this` | ||
validateArgumentsLength(length, 1); | ||
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