Skip to content

Commit c3ce34f

Browse files
authored
Merge pull request #450 from saschanaz/url
Add URL types
2 parents 4cb11ba + b86f405 commit c3ce34f

File tree

5 files changed

+51
-54
lines changed

5 files changed

+51
-54
lines changed

baselines/dom.generated.d.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13972,7 +13972,7 @@ interface URL {
1397213972
search: string;
1397313973
readonly searchParams: URLSearchParams;
1397413974
username: string;
13975-
toString(): string;
13975+
toJSON(): string;
1397613976
}
1397713977

1397813978
declare var URL: {
@@ -13982,6 +13982,9 @@ declare var URL: {
1398213982
revokeObjectURL(url: string): void;
1398313983
};
1398413984

13985+
type webkitURL = URL;
13986+
declare var webkitURL: typeof URL;
13987+
1398513988
interface URLSearchParams {
1398613989
/**
1398713990
* Appends a specified key/value pair as a new search parameter.
@@ -14007,11 +14010,13 @@ interface URLSearchParams {
1400714010
* Sets the value associated to a given search parameter to the given value. If there were several values, delete the others.
1400814011
*/
1400914012
set(name: string, value: string): void;
14013+
sort(): void;
14014+
forEach(callbackfn: (value: string, key: string, parent: URLSearchParams) => void, thisArg?: any): void;
1401014015
}
1401114016

1401214017
declare var URLSearchParams: {
1401314018
prototype: URLSearchParams;
14014-
new (init?: string | URLSearchParams): URLSearchParams;
14019+
new(init?: string[][] | Record<string, string> | string | URLSearchParams): URLSearchParams;
1401514020
};
1401614021

1401714022
interface VRDisplay extends EventTarget {

baselines/webworker.generated.d.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,7 +1452,7 @@ interface URL {
14521452
search: string;
14531453
readonly searchParams: URLSearchParams;
14541454
username: string;
1455-
toString(): string;
1455+
toJSON(): string;
14561456
}
14571457

14581458
declare var URL: {
@@ -1487,11 +1487,13 @@ interface URLSearchParams {
14871487
* Sets the value associated to a given search parameter to the given value. If there were several values, delete the others.
14881488
*/
14891489
set(name: string, value: string): void;
1490+
sort(): void;
1491+
forEach(callbackfn: (value: string, key: string, parent: URLSearchParams) => void, thisArg?: any): void;
14901492
}
14911493

14921494
declare var URLSearchParams: {
14931495
prototype: URLSearchParams;
1494-
new (init?: string | URLSearchParams): URLSearchParams;
1496+
new(init?: string[][] | Record<string, string> | string | URLSearchParams): URLSearchParams;
14951497
};
14961498

14971499
interface WebSocketEventMap {

inputfiles/addedTypes.json

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -469,63 +469,14 @@
469469
},
470470
"URLSearchParams": {
471471
"name": "URLSearchParams",
472-
"methods": {
473-
"method": {
474-
"append": {
475-
"name": "append",
476-
"override-signatures": [
477-
"append(name: string, value: string): void"
478-
]
479-
},
480-
"delete": {
481-
"name": "delete",
482-
"override-signatures": [
483-
"delete(name: string): void"
484-
]
485-
},
486-
"get": {
487-
"name": "get",
488-
"override-signatures": [
489-
"get(name: string): string | null"
490-
]
491-
},
492-
"getAll": {
493-
"name": "getAll",
494-
"override-signatures": [
495-
"getAll(name: string): string[]"
496-
]
497-
},
498-
"has": {
499-
"name": "has",
500-
"override-signatures": [
501-
"has(name: string): boolean"
502-
]
503-
},
504-
"set": {
505-
"name": "set",
506-
"override-signatures": [
507-
"set(name: string, value: string): void"
508-
]
509-
}
510-
}
511-
},
512472
"constructor": {
513473
"override-signatures": [
514-
"new (init?: string | URLSearchParams): URLSearchParams"
474+
"new(init?: string[][] | Record<string, string> | string | URLSearchParams): URLSearchParams"
515475
]
516476
}
517477
},
518478
"URL": {
519479
"name": "URL",
520-
"properties": {
521-
"property": {
522-
"searchParams": {
523-
"name": "searchParams",
524-
"read-only": 1,
525-
"override-type": "URLSearchParams"
526-
}
527-
}
528-
},
529480
"methods": {
530481
"method": {
531482
"createObjectURL": {

inputfiles/idl/URL.widl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
[Constructor(USVString url, optional USVString base),
2+
Exposed=(Window,Worker),
3+
LegacyWindowAlias=webkitURL]
4+
interface URL {
5+
stringifier attribute USVString href;
6+
readonly attribute USVString origin;
7+
attribute USVString protocol;
8+
attribute USVString username;
9+
attribute USVString password;
10+
attribute USVString host;
11+
attribute USVString hostname;
12+
attribute USVString port;
13+
attribute USVString pathname;
14+
attribute USVString search;
15+
[SameObject] readonly attribute URLSearchParams searchParams;
16+
attribute USVString hash;
17+
18+
USVString toJSON();
19+
};
20+
21+
[Constructor(optional (sequence<sequence<USVString>> or record<USVString, USVString> or USVString) init = ""),
22+
Exposed=(Window,Worker)]
23+
interface URLSearchParams {
24+
void append(USVString name, USVString value);
25+
void delete(USVString name);
26+
USVString? get(USVString name);
27+
sequence<USVString> getAll(USVString name);
28+
boolean has(USVString name);
29+
void set(USVString name, USVString value);
30+
31+
void sort();
32+
33+
iterable<USVString, USVString>;
34+
stringifier;
35+
};

inputfiles/idlSources.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555
"url": "https://w3c.github.io/touch-events/",
5656
"title": "Touch Events"
5757
},
58+
{
59+
"url": "https://url.spec.whatwg.org/",
60+
"title": "URL"
61+
},
5862
{
5963
"url": "https://www.w3.org/TR/user-timing-2/",
6064
"title": "User Timing"

0 commit comments

Comments
 (0)