Skip to content

Commit 98217ff

Browse files
author
Rémi Hau
committed
fix: not call destroy on destroyed step
1 parent e256dcb commit 98217ff

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

shepherd.js/src/step.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ export class Step extends Evented {
447447

448448
if (isHTMLElement(this.el)) {
449449
this.el.remove();
450-
this.el = null;
450+
this.el = undefined;
451451
}
452452

453453
this._updateStepTargetOnHide();

shepherd.js/test/unit/step.spec.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,19 @@ describe('Tour | Step', () => {
441441
).toBeTruthy();
442442
});
443443

444+
it('not calls destroy on the step if the step was destroyed', () => {
445+
const step = new Step(tour, {});
446+
let destroyCalled = false;
447+
step.el = document.createElement('a');
448+
step.destroy()
449+
step.destroy = () => (destroyCalled = true);
450+
step._setupElements();
451+
expect(
452+
destroyCalled,
453+
'_setupElements method not called destroy if the step was destroyed'
454+
).toBeFalsy();
455+
});
456+
444457
it('calls destroy on the tooltip if it already exists', () => {
445458
const step = new Step(tour, {});
446459
let destroyCalled = false;

0 commit comments

Comments
 (0)