Skip to content

Commit

Permalink
fix(core): 🐛 fix data-barba-history="replace" attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
xavierfoucrier committed Mar 29, 2023
1 parent 1a6a597 commit 8e38a8f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions packages/core/src/utils/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ export class History {
public add(url: string, trigger: Trigger): void {
// If no state, it will be updated later.
const ns = 'tmp';
const index = this.size;
const action = this._getAction(trigger);
const state: IStateItem = {
ns,
Expand All @@ -124,12 +123,21 @@ export class History {
url,
};

this._states.push(state);
this._pointer = index;
switch (action) {
case 'push':
this._pointer = this.size;
this._states.push(state);
break;
case 'replace':
this.set(this._pointer, state);
break;
/* istanbul ignore next */
default:
}

const item: IHistoryItem = {
from: this._session,
index,
index: this._pointer,
states: [...this._states],
};

Expand Down

0 comments on commit 8e38a8f

Please sign in to comment.