@tanstack/router-core 0.0.1-beta.197 → 0.0.1-beta.199

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -205,6 +205,12 @@
205
205
  scheduled = Promise.resolve().then(() => flush());
206
206
  }
207
207
  };
208
+ const onPushPop = () => {
209
+ currentLocation = parseLocation(getHref(), window.history.state);
210
+ history.update();
211
+ };
212
+ var originalPushState = window.history.pushState;
213
+ var originalReplaceState = window.history.replaceState;
208
214
  const history = createHistory({
209
215
  getLocation,
210
216
  pushState: (path, state, onUpdate) => queueHistoryAction('push', path, state, onUpdate),
@@ -215,29 +221,21 @@
215
221
  createHref: path => createHref(path),
216
222
  flush,
217
223
  destroy: () => {
218
- window.history.pushState = pushState;
219
- window.history.replaceState = replaceState;
220
- window.removeEventListener(pushStateEvent, history.update);
221
- window.removeEventListener(popStateEvent, history.update);
224
+ window.history.pushState = originalPushState;
225
+ window.history.replaceState = originalReplaceState;
226
+ window.removeEventListener(pushStateEvent, onPushPop);
227
+ window.removeEventListener(popStateEvent, onPushPop);
222
228
  }
223
229
  });
224
- window.addEventListener(pushStateEvent, () => {
225
- currentLocation = parseLocation(getHref(), window.history.state);
226
- history.update;
227
- });
228
- window.addEventListener(popStateEvent, () => {
229
- currentLocation = parseLocation(getHref(), window.history.state);
230
- history.update;
231
- });
232
- var pushState = window.history.pushState;
230
+ window.addEventListener(pushStateEvent, onPushPop);
231
+ window.addEventListener(popStateEvent, onPushPop);
233
232
  window.history.pushState = function () {
234
- let res = pushState.apply(window.history, arguments);
233
+ let res = originalPushState.apply(window.history, arguments);
235
234
  if (tracking) history.update();
236
235
  return res;
237
236
  };
238
- var replaceState = window.history.replaceState;
239
237
  window.history.replaceState = function () {
240
- let res = replaceState.apply(window.history, arguments);
238
+ let res = originalReplaceState.apply(window.history, arguments);
241
239
  if (tracking) history.update();
242
240
  return res;
243
241
  };