[79a0317] | 1 | 'use strict';
|
---|
| 2 | var defineBuiltIn = require('../internals/define-built-in');
|
---|
| 3 | var uncurryThis = require('../internals/function-uncurry-this');
|
---|
| 4 | var toString = require('../internals/to-string');
|
---|
| 5 | var validateArgumentsLength = require('../internals/validate-arguments-length');
|
---|
| 6 |
|
---|
| 7 | var $URLSearchParams = URLSearchParams;
|
---|
| 8 | var URLSearchParamsPrototype = $URLSearchParams.prototype;
|
---|
| 9 | var getAll = uncurryThis(URLSearchParamsPrototype.getAll);
|
---|
| 10 | var $has = uncurryThis(URLSearchParamsPrototype.has);
|
---|
| 11 | var params = new $URLSearchParams('a=1');
|
---|
| 12 |
|
---|
| 13 | // `undefined` case is a Chromium 117 bug
|
---|
| 14 | // https://bugs.chromium.org/p/v8/issues/detail?id=14222
|
---|
| 15 | if (params.has('a', 2) || !params.has('a', undefined)) {
|
---|
| 16 | defineBuiltIn(URLSearchParamsPrototype, 'has', function has(name /* , value */) {
|
---|
| 17 | var length = arguments.length;
|
---|
| 18 | var $value = length < 2 ? undefined : arguments[1];
|
---|
| 19 | if (length && $value === undefined) return $has(this, name);
|
---|
| 20 | var values = getAll(this, name); // also validates `this`
|
---|
| 21 | validateArgumentsLength(length, 1);
|
---|
| 22 | var value = toString($value);
|
---|
| 23 | var index = 0;
|
---|
| 24 | while (index < values.length) {
|
---|
| 25 | if (values[index++] === value) return true;
|
---|
| 26 | } return false;
|
---|
| 27 | }, { enumerable: true, unsafe: true });
|
---|
| 28 | }
|
---|