Skip to content

Commit 3c4e1eb

Browse files
committed
Fix: don't pass nextStep.element to onbeforechange callback if it s not exists yet
1 parent 7bb15c2 commit 3c4e1eb

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/core/steps.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ export function nextStep() {
5959
if (typeof this._introBeforeChangeCallback !== "undefined") {
6060
continueStep = this._introBeforeChangeCallback.call(
6161
this,
62-
nextStep && nextStep.element
62+
nextStep &&
63+
(elementBySelectorNotExists(nextStep) ? undefined : nextStep.element)
6364
);
6465
}
6566

@@ -79,16 +80,23 @@ export function nextStep() {
7980
return;
8081
}
8182

82-
if (
83-
typeof nextStep._element === "string" &&
84-
document.querySelector(nextStep._element) === null
85-
) {
83+
if (elementBySelectorNotExists(nextStep)) {
8684
waitForElement(nextStep._element, () => showElement.call(this, nextStep));
8785
} else {
8886
showElement.call(this, nextStep);
8987
}
9088
}
9189

90+
/**
91+
* Return true if element locates by selector and doesn't exists yet
92+
*/
93+
function elementBySelectorNotExists(step) {
94+
return (
95+
typeof step._element === "string" &&
96+
document.querySelector(step._element) === null
97+
);
98+
}
99+
92100
/**
93101
* Go to previous step on intro
94102
*

0 commit comments

Comments
 (0)