@tarojs/router 3.3.15 → 3.3.16

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.
@@ -76,16 +76,23 @@ class Stacks {
76
76
  getItem(index) {
77
77
  return this.stacks[index];
78
78
  }
79
+ getLastIndex(pathname) {
80
+ const list = [...this.stacks].reverse();
81
+ return list.findIndex(page => { var _a; return ((_a = page.path) === null || _a === void 0 ? void 0 : _a.replace(/\?.*/g, '')) === pathname; });
82
+ }
79
83
  getDelta(pathname) {
80
84
  if (this.backDelta >= 1) {
81
85
  return this.backDelta;
82
86
  }
83
87
  // NOTE: 此处为了修复浏览器后退多级页面,在大量重复路由状况下可能出现判断错误的情况 (增强判断能力只能考虑在 query 中新增参数来判断,暂时搁置)
84
- const prevIndex = this.stacks.findIndex(r => { var _a; return ((_a = r.path) === null || _a === void 0 ? void 0 : _a.replace(/\?.*/g, '')) === pathname; });
85
- return this.length - 1 - prevIndex;
88
+ return this.getLastIndex(pathname) || 1;
86
89
  }
87
90
  getPrevIndex(pathname) {
88
- return this.length - 1 - this.getDelta(pathname);
91
+ const lastIndex = this.getLastIndex(pathname);
92
+ if (lastIndex < 0) {
93
+ return -1;
94
+ }
95
+ return this.length - 1 - lastIndex;
89
96
  }
90
97
  pop() {
91
98
  return this.stacks.pop();
@@ -1520,11 +1527,11 @@ const qs = function (stamp = 0) {
1520
1527
 
1521
1528
  /* eslint-disable dot-notation */
1522
1529
  function pageOnReady(page, onLoad = true) {
1523
- var _a;
1530
+ var _a, _b;
1524
1531
  const pageEl = document.getElementById(page.path);
1525
1532
  if (pageEl && !(pageEl === null || pageEl === void 0 ? void 0 : pageEl['__isReady'])) {
1526
1533
  const el = pageEl.firstElementChild;
1527
- (_a = el === null || el === void 0 ? void 0 : el['componentOnReady']) === null || _a === void 0 ? void 0 : _a.call(el).then(() => {
1534
+ (_b = (_a = el === null || el === void 0 ? void 0 : el['componentOnReady']) === null || _a === void 0 ? void 0 : _a.call(el)) === null || _b === void 0 ? void 0 : _b.then(() => {
1528
1535
  requestAnimationFrame(() => {
1529
1536
  page.onReady();
1530
1537
  pageEl['__isReady'] = true;
@@ -1668,7 +1675,7 @@ function createRouter(app, config, framework) {
1668
1675
  }
1669
1676
  shouldLoad = true;
1670
1677
  }
1671
- if (shouldLoad) {
1678
+ if (shouldLoad || stacks.length < 1) {
1672
1679
  const el = (_c = element.default) !== null && _c !== void 0 ? _c : element;
1673
1680
  const loadConfig = Object.assign({}, pageConfig);
1674
1681
  const stacksIndex = stacks.length;