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 and billyvg committed Apr 26, 2024
1 parent ca4d2b8 commit e2ecbfe
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 @@ -814,7 +814,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 e2ecbfe

Please sign in to comment.