mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-24 05:06:02 +08:00
Fix History.js definitions and tests
This commit is contained in:
@@ -1,17 +1,19 @@
|
||||
/// <reference path="history.d.ts" />
|
||||
|
||||
if (!History.enabled) {
|
||||
return false;
|
||||
}
|
||||
function tests() {
|
||||
if (!Historyjs.enabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
History.Adapter.bind(window, 'statechange', () => {
|
||||
var State = History.getState();
|
||||
History.log(State.data, State.title, State.url);
|
||||
});
|
||||
Historyjs.Adapter.bind(window, 'statechange', () => {
|
||||
var State = Historyjs.getState();
|
||||
Historyjs.log(State.data, State.title, State.url);
|
||||
});
|
||||
|
||||
History.pushState({ state: 1 }, "State 1", "?state=1");
|
||||
History.pushState({ state: 2 }, "State 2", "?state=2");
|
||||
History.replaceState({ state: 3 }, "State 3", "?state=3");
|
||||
History.pushState(null, null, "?state=4");
|
||||
History.back();
|
||||
History.go(2);
|
||||
Historyjs.pushState({ state: 1 }, "State 1", "?state=1");
|
||||
Historyjs.pushState({ state: 2 }, "State 2", "?state=2");
|
||||
Historyjs.replaceState({ state: 3 }, "State 3", "?state=3");
|
||||
Historyjs.pushState(null, null, "?state=4");
|
||||
Historyjs.back();
|
||||
Historyjs.go(2);
|
||||
}
|
||||
6
history/history.d.ts
vendored
6
history/history.d.ts
vendored
@@ -10,7 +10,7 @@ interface HistoryAdapter {
|
||||
onDomLoad(callback);
|
||||
}
|
||||
|
||||
interface History {
|
||||
interface Historyjs {
|
||||
enabled: bool;
|
||||
pushState(data, title, url);
|
||||
replaceState(data, title, url);
|
||||
@@ -22,4 +22,6 @@ interface History {
|
||||
go(X);
|
||||
log(...messages: any[]);
|
||||
debug(...messages: any[]);
|
||||
}
|
||||
}
|
||||
|
||||
declare var Historyjs: Historyjs;
|
||||
Reference in New Issue
Block a user