-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
throw on non-serializable state PUSH navigation
- Loading branch information
1 parent
fdb9069
commit 7fe2db3
Showing
5 changed files
with
46 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@remix-run/router": patch | ||
"react-router-dom": patch | ||
--- | ||
|
||
Re-throw `DOMException` (`DataCloneError`) when attempting to perform a `PUSH` navigation with non-serializable state. |
19 changes: 19 additions & 0 deletions
19
packages/router/__tests__/TestSequences/PushStateInvalid.ts
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import type { DOMWindow } from "jsdom"; | ||
import type { History } from "../../history"; | ||
|
||
export default function PushState(history: History, window: DOMWindow) { | ||
let err = new DOMException("ERROR", "DataCloneError"); | ||
jest.spyOn(window.history, "pushState").mockImplementation(() => { | ||
throw err; | ||
}); | ||
|
||
expect(history.location).toMatchObject({ | ||
pathname: "/", | ||
}); | ||
|
||
expect(() => | ||
history.push("/home?the=query#the-hash", { invalid: () => {} }) | ||
).toThrow(err); | ||
|
||
expect(history.location.pathname).toBe("/"); | ||
} |
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
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
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