@tanstack/history
Advanced tools
Comparing version 1.49.0 to 1.49.7
@@ -18,2 +18,3 @@ export interface NavigateOptions { | ||
notify: () => void; | ||
_ignoreSubscribers?: boolean; | ||
} | ||
@@ -20,0 +21,0 @@ export interface HistoryLocation extends ParsedPath { |
@@ -131,4 +131,9 @@ const pushStateEvent = "pushstate"; | ||
} | ||
const caller = next.isPush ? originalPushState : originalReplaceState; | ||
caller.call(win.history, next.state, "", next.href); | ||
history._ignoreSubscribers = true; | ||
(next.isPush ? win.history.pushState : win.history.replaceState)( | ||
next.state, | ||
"", | ||
next.href | ||
); | ||
history._ignoreSubscribers = false; | ||
next = void 0; | ||
@@ -187,3 +192,3 @@ scheduled = void 0; | ||
const res = originalPushState.apply(win.history, args); | ||
onPushPop(); | ||
if (!history._ignoreSubscribers) onPushPop(); | ||
return res; | ||
@@ -193,3 +198,3 @@ }; | ||
const res = originalReplaceState.apply(win.history, args); | ||
onPushPop(); | ||
if (!history._ignoreSubscribers) onPushPop(); | ||
return res; | ||
@@ -196,0 +201,0 @@ }; |
{ | ||
"name": "@tanstack/history", | ||
"version": "1.49.0", | ||
"version": "1.49.7", | ||
"description": "Modern and scalable routing for React applications", | ||
@@ -5,0 +5,0 @@ "author": "Tanner Linsley", |
@@ -22,2 +22,3 @@ // While the public API was clearly inspired by the "history" npm package, | ||
notify: () => void | ||
_ignoreSubscribers?: boolean | ||
} | ||
@@ -242,6 +243,15 @@ | ||
// We use the original push/replace calls here to ensure that | ||
// we do not notify subscribers about this push/replace call | ||
const caller = next.isPush ? originalPushState : originalReplaceState | ||
caller.call(win.history, next.state, '', next.href) | ||
// We need to ignore any updates to the subscribers while we update the browser history | ||
history._ignoreSubscribers = true | ||
// Update the browser history | ||
;(next.isPush ? win.history.pushState : win.history.replaceState)( | ||
next.state, | ||
'', | ||
next.href, | ||
) | ||
// Stop ignoring subscriber updates | ||
history._ignoreSubscribers = false | ||
// Reset the nextIsPush flag and clear the scheduled update | ||
@@ -321,3 +331,3 @@ next = undefined | ||
const res = originalPushState.apply(win.history, args) | ||
onPushPop() | ||
if (!history._ignoreSubscribers) onPushPop() | ||
return res | ||
@@ -328,3 +338,3 @@ } | ||
const res = originalReplaceState.apply(win.history, args) | ||
onPushPop() | ||
if (!history._ignoreSubscribers) onPushPop() | ||
return res | ||
@@ -331,0 +341,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
72794
1012