Skip to content

Commit

Permalink
lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
peuter committed Mar 9, 2024
1 parent 31a5056 commit 3c560b9
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions source/class/cv/report/Record.js
Expand Up @@ -312,8 +312,8 @@ qx.Class.define('cv.report.Record', {
button: nativeEvent.button,
clientX: Math.round(nativeEvent.clientX),
clientY: Math.round(nativeEvent.clientY),
currentTarget: nativeEvent.currentTarget ? this.__getDomPath(nativeEvent.currentTarget) : undefined,
relatedTarget: nativeEvent.relatedTarget ? this.__getDomPath(nativeEvent.relatedTarget) : undefined,
currentTarget: this.__getDomPath(nativeEvent.currentTarget) ?? undefined,
relatedTarget: this.__getDomPath(nativeEvent.relatedTarget) ?? undefined,
pageX: nativeEvent.pageX ? Math.round(nativeEvent.pageX) : undefined,
pageY: nativeEvent.pageY ? Math.round(nativeEvent.pageY) : undefined,
returnValue: nativeEvent.returnValue,
Expand Down Expand Up @@ -426,7 +426,14 @@ qx.Class.define('cv.report.Record', {
this.record(cv.report.Record.USER, 'scroll', data);
},

/**
* @param el {Element|Node|Window|undefined}
* @return {string} CSS selector to element
*/
__getDomPath(el) {
if (!el) {
return '';
}
if (el === window) {
return 'Window';
} else if (el === document) {
Expand All @@ -448,19 +455,18 @@ qx.Class.define('cv.report.Record', {
const sel = stack.join('>');
if (document.querySelector(sel) !== origEl) {
this.debug('wrong selector: ' + sel + ', looking for', origEl, 'found', document.querySelector(sel));
return;
return '';
}
return sel;
} else {
stack.unshift(el.nodeName.toLowerCase() + ':nth-child(' + sibIndex + ')');
}
stack.unshift(el.nodeName.toLowerCase() + ':nth-child(' + sibIndex + ')');
el = el.parentElement;
}

const sel = stack.slice(1).join('>'); // removes the html element
if (document.querySelector(sel) !== origEl) {
this.debug('wrong selector: ' + sel + ', looking for', origEl, 'found', document.querySelector(sel));
return;
return '';
}
return sel;
},
Expand Down

0 comments on commit 3c560b9

Please sign in to comment.