summaryrefslogtreecommitdiff
path: root/node_modules/swup/src/helpers/history.ts
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/swup/src/helpers/history.ts')
-rwxr-xr-xnode_modules/swup/src/helpers/history.ts37
1 files changed, 0 insertions, 37 deletions
diff --git a/node_modules/swup/src/helpers/history.ts b/node_modules/swup/src/helpers/history.ts
deleted file mode 100755
index e7ea2f6c..00000000
--- a/node_modules/swup/src/helpers/history.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-import { getCurrentUrl } from './getCurrentUrl.js';
-
-export interface HistoryState {
- url: string;
- source: 'swup';
- random: number;
- index?: number;
- [key: string]: unknown;
-}
-
-type HistoryData = Record<string, unknown>;
-
-/** Create a new history record with a custom swup identifier. */
-export const createHistoryRecord = (url: string, data: HistoryData = {}): void => {
- url = url || getCurrentUrl({ hash: true });
- const state: HistoryState = {
- url,
- random: Math.random(),
- source: 'swup',
- ...data
- };
- window.history.pushState(state, '', url);
-};
-
-/** Update the current history record with a custom swup identifier. */
-export const updateHistoryRecord = (url: string | null = null, data: HistoryData = {}): void => {
- url = url || getCurrentUrl({ hash: true });
- const currentState = (window.history.state as HistoryState) || {};
- const state: HistoryState = {
- ...currentState,
- url,
- random: Math.random(),
- source: 'swup',
- ...data
- };
- window.history.replaceState(state, '', url);
-};