Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 8 additions & 6 deletions baselines/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7536,11 +7536,12 @@ declare var HashChangeEvent: {
interface History {
readonly length: number;
readonly state: any;
back(distance?: any): void;
forward(distance?: any): void;
go(delta?: any): void;
pushState(statedata: any, title?: string, url?: string): void;
replaceState(statedata: any, title?: string, url?: string): void;
scrollRestoration: ScrollRestoration;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

is it a read only property? If so add the modifier

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

back(): void;
forward(): void;
go(delta?: number): void;
pushState(data: any, title: string, url?: string | null): void;

@zhengbli Zhengbo Li (zhengbli) Aug 29, 2016 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

optional parameter doesn't need the | null annotation, it gets that automatically. url?: string is good enough.
Also, if missing the value of the optional parameter should be undefined I think

@falsandtru falsandtru (falsandtru) Aug 29, 2016 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Its signature in spec is void pushState(any data, DOMString title, optional USVString? url = null);. So it needs to accept a null value as an explicit default value, and should be optional.

https://html.spec.whatwg.org/multipage/browsers.html#the-history-interface

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ah, makes sense. Thanks

replaceState(data: any, title: string, url?: string | null): void;
}

declare var History: {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

there is a var History i find in most browsers. why was this removed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The History is the prototype for the type. the constructor can not be called directly, but that is the same as the rest of the HTML*Element classes as well. so we should keep both a type and a value for History. we already have a value history: History on Window and the global object.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Okay, fixed.

Expand Down Expand Up @@ -14622,4 +14623,5 @@ type ScrollBehavior = "auto" | "instant" | "smooth";
type ScrollLogicalPosition = "start" | "center" | "end" | "nearest";
type IDBValidKey = number | string | Date | IDBArrayKey;
type BufferSource = ArrayBuffer | ArrayBufferView;
type MouseWheelEvent = WheelEvent;
type MouseWheelEvent = WheelEvent;
type ScrollRestoration = "auto" | "manual";
12 changes: 12 additions & 0 deletions inputfiles/addedTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -1175,5 +1175,17 @@
"kind": "extends",
"baseInterface": "ParentNode",
"interface": "DocumentFragment"
},
{
"kind": "typedef",
"name": "ScrollRestoration",
"flavor": "DOM",
"type": "\"auto\" | \"manual\""
},
{
"kind": "property",
"interface": "History",
"name": "scrollRestoration",
"type": "ScrollRestoration"
}
]
32 changes: 31 additions & 1 deletion inputfiles/overridingTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -815,5 +815,35 @@
"interface": "Window",
"name": "opener",
"type": "any"
}
},
{
"kind": "method",
"interface": "History",
"name": "back",
"signatures": ["back(): void"]
},
{
"kind": "method",
"interface": "History",
"name": "forward",
"signatures": ["forward(): void"]
},
{
"kind": "method",
"interface": "History",
"name": "go",
"signatures": ["go(delta?: number): void"]
},
{
"kind": "method",
"interface": "History",
"name": "pushState",
"signatures": ["pushState(data: any, title: string, url?: string | null): void"]
},
{
"kind": "method",
"interface": "History",
"name": "replaceState",
"signatures": ["replaceState(data: any, title: string, url?: string | null): void"]
}
]