Skip to content

Commit

Permalink
fix(snaptshot): Ensure attr.name is defined when collecting element…
Browse files Browse the repository at this point in the history
… attributes (#160)

Probably fixes
getsentry/sentry-javascript#10292

Not sure how `attr.name` could be undefined here but according to the
issue, it happens and we should probably guard adding the attribute.
  • Loading branch information
Lms24 authored Jan 25, 2024
1 parent 8c8a8ea commit 04b3de5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/rrweb-snapshot/src/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,9 @@ function serializeElementNode(
const len = n.attributes.length;
for (let i = 0; i < len; i++) {
const attr = n.attributes[i];
if (!ignoreAttribute(tagName, attr.name, attr.value)) {
// Looks like `attr.name` can be undefined although the types say differently
// see: https://github.com/getsentry/sentry-javascript/issues/10292
if (attr.name && !ignoreAttribute(tagName, attr.name, attr.value)) {
attributes[attr.name] = transformAttribute(
doc,
tagName,
Expand Down

0 comments on commit 04b3de5

Please sign in to comment.