Skip to content

Commit 329c505

Browse files
committed
product tour id refactor and nested element detection
1 parent 4558906 commit 329c505

File tree

8 files changed

+23
-8
lines changed

8 files changed

+23
-8
lines changed

.DS_Store

2 KB
Binary file not shown.

build/cjs/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/esm/index.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gleap",
3-
"version": "14.0.3",
3+
"version": "14.0.4",
44
"main": "build/cjs/index.js",
55
"module": "build/esm/index.mjs",
66
"exports": {

published/14.0.4/index.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

published/latest/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/GleapProductTours.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,12 @@ export default class GleapProductTours {
106106
const element = gleapTourObj.getActiveElement();
107107

108108
if (step?.mode === "CLICK" && evnt?.target !== element) {
109-
// Ignore clicks outside of the actual element.
110-
return;
109+
const isInsideElement = element.contains(evnt?.target);
110+
111+
if (!isInsideElement) {
112+
// Ignore clicks outside of the actual element.
113+
return;
114+
}
111115
}
112116

113117
if ((element && element.tagName === 'INPUT') || step.mode === "INPUT" || evnt?.target?.id.includes("tooltip-svg")) {

src/GleapTours.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,18 @@ const GleapTours = function () {
224224
}
225225
function highlight(step, attemptTime = 2000) {
226226
const { element } = step;
227-
let elemObj = typeof element === "string" ? document.querySelector(element) : element;
228-
227+
let elemObj = element;
228+
if (typeof elemObj === "string") {
229+
try {
230+
elemObj = document.querySelector(element);
231+
} catch (error) {
232+
// This will escape colons within IDs but not affect pseudo-classes or other valid uses of colons
233+
let refactoredElement = element.replace(/(#[^#\s]+)/g, function(match) {
234+
return match.replace(/:/g, '\\:');
235+
});
236+
elemObj = document.querySelector(refactoredElement);
237+
}
238+
}
229239
if (element && !elemObj && attemptTime >= 0) {
230240
setTimeout(() => {
231241
hidePopover();

0 commit comments

Comments
 (0)