Skip to content

Commit 32e4d83

Browse files
committed
try/catch serializing DOM element targets
1 parent 149a6c9 commit 32e4d83

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/raven.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,9 +637,20 @@ Raven.prototype = {
637637

638638
self._lastCapturedEvent = evt;
639639
var elem = evt.target;
640+
641+
var target;
642+
643+
// try/catch htmlTreeAsString because it's particularly complicated, and
644+
// just accessing the DOM incorrectly can throw an exception in some circumstances.
645+
try {
646+
target = htmlTreeAsString(elem);
647+
} catch (e) {
648+
target = '<unknown>';
649+
}
650+
640651
self.captureBreadcrumb('ui_event', {
641652
type: evtName,
642-
target: htmlTreeAsString(elem)
653+
target: target
643654
});
644655
};
645656
},

0 commit comments

Comments
 (0)