Skip to content

Commit

Permalink
chore: code maintenance
Browse files Browse the repository at this point in the history
  • Loading branch information
kkruk-sumo committed Jun 16, 2021
1 parent 6209b38 commit 7ee1d07
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,13 @@ export class UserInteractionInstrumentation extends InstrumentationBase<unknown>
* @param eventName
*/
private _createSpan(
element: HTMLElement,
element: EventTarget | null | undefined,
eventName: string,
parentSpan?: api.Span | undefined
): api.Span | undefined {
if (!(element instanceof HTMLElement)) {
return undefined;
}
if (!element.getAttribute) {
return undefined;
}
Expand Down Expand Up @@ -274,10 +277,7 @@ export class UserInteractionInstrumentation extends InstrumentationBase<unknown>
if (once) {
plugin.removePatchedListener(this, type, listener);
}
const span =
target instanceof HTMLElement
? plugin._createSpan(target, type, parentSpan)
: undefined;
const span = plugin._createSpan(target, type, parentSpan);
if (span) {
if (event) {
plugin._eventsSpanMap.set(event, span);
Expand Down Expand Up @@ -449,7 +449,7 @@ export class UserInteractionInstrumentation extends InstrumentationBase<unknown>
const target = event?.target;
let span: api.Span | undefined;
const activeZone = this;
if (target instanceof HTMLElement) {
if (target) {
span = plugin._createSpan(target, task.eventName);
if (span) {
plugin._incrementTask(span);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const FILE_URL =

describe('UserInteractionInstrumentation', () => {
afterEach(() => {
// clear body from elements created by some tests to make sure they are independent
while (document.body.lastChild) {
document.body.removeChild(document.body.lastChild);
}
Expand Down

0 comments on commit 7ee1d07

Please sign in to comment.