-
Notifications
You must be signed in to change notification settings - Fork 36
Description
firstly, thank you for bootstrap-tourist. It looks very promising and I cant wait to play with it properly.
I've just set it up on one of my sites just to see how much I can break it and have come across what I believe is an incorrect isOrphan detection.
Created the tour and added 2 steps with both steps intentionally assigned to non-existent elements.
jQuery(document).ready( function() {
var tour = new Tour({
framework: 'bootstrap3',
sanitizeFunction: function(stepContent) {
//return DOMPurify.sanitize(stepContent);
return stepContent;
},
onPreviouslyEnded: function (tour) {
tour.restart();
},
steps: [{
placement: 'right',
showIfUnintendedOrphan: true,
//orphan:true,
showProgressBar: false,
showProgressText: false,
backdrop: true,
element: '#img1', //intentionally set to non-existent page (DOM) element
title: 'Step One',
content: '<p>This is the preview of your popover</p><p>Set your options at the left so your popovers will match natively with your product</p>'
},
{
placement: 'left',
showIfUnintendedOrphan: true,
//orphan: true,
backdrop: true,
showProgressBar: false,
showProgressText: false,
element: '#imgxx', //intentionally set to non-existent page (DOM) element
title: 'Step Two',
content: '<p>This is the preview of your popover</p><p>Set your options at the left so your popovers will match natively with your product</p>',
}]
});
tour.start();
});
I added some further debugging in the code to check the isOrphan function and then launched the tour.
when the tour starts, the first step is positioned correctly in the center of the page and the debugging output shows:
checking if step is an orphan....
- step.orphan: false
- step.element: #img1
- step.placement: right
- $(step.element).length: 0
- $(step.element) hidden: false
orphan status is: true
I click the next button and step 2 displayed as intended (ie, it satisfied all the conditions to be declared an orphan).
I then click the back button and this is where the strange behaviour comes in. The step (step 1) is again displayed however it is now positioned at the very top of the page and the step.element, instead of being '#img1' is 'body'
debugging output is as follows:
checking if step is an orphan....
- step.orphan: false
- step.element: body
- step.placement: top
- $(step.element).length: 1
- $(step.element) hidden: false
orphan status is: false
from here on in, moving through the tour, whether forwards or backwards, the steps stay positioned at the top of the page and the step.element remains assigned to 'body'.
I hope I've made sense :)