-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Klaus Zanders
committed
Jul 29, 2024
1 parent
e3fc32c
commit 9824cd2
Showing
2 changed files
with
11 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
import { StreamActions, StreamElement } from '@hotwired/turbo'; | ||
|
||
export function registerHistoryAction() { | ||
StreamActions.history = function historyStreamAction(this: StreamElement) { | ||
const url = this.getAttribute("url"); | ||
const method = this.getAttribute("method"); | ||
StreamActions.history = function historyStreamAction(this:StreamElement) { | ||
const url = this.getAttribute('url'); | ||
const method = this.getAttribute('method'); | ||
|
||
switch (method) { | ||
case "replace": | ||
window.history.replaceState({ href: url }, "", url) | ||
case 'replace': | ||
window.history.replaceState({ href: url }, '', url); | ||
break; | ||
case "push": | ||
window.history.pushState({ href: url }, "", url) | ||
case 'push': | ||
window.history.pushState({ href: url }, '', url); | ||
break; | ||
default: | ||
throw new Error(`Unknown history method: ${method}`); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters