Skip to content

Commit d3b89d6

Browse files
jaladalucashalfpennywaltjones
authored
Handle null nextDescription in describeElement (#1378)
* Handle null nextDescription in describeElement Co-authored-by: Lucas Halfpenny <lucashalfpenny@gmail.com> * Add a regression test for genElement handling elements with no tagName Co-authored-by: Lucas Halfpenny <lucashalfpenny@gmail.com> * lint fix --------- Co-authored-by: Lucas Halfpenny <lucashalfpenny@gmail.com> Co-authored-by: Walt Jones <walt.jones@rollbar.com>
1 parent ab5eafb commit d3b89d6

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/browser/domUtility.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function treeToArray(elem) {
3434
var nextDescription;
3535
for (var height = 0; elem && height < MAX_HEIGHT; height++) {
3636
nextDescription = describeElement(elem);
37-
if (nextDescription.tagName === 'html') {
37+
if (!nextDescription || nextDescription.tagName === 'html') {
3838
break;
3939
}
4040
out.unshift(nextDescription);

test/browser.domUtility.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ describe('treeToArray', function () {
118118
const arr = d.treeToArray(e1);
119119
expect(arr.length).to.eql(5);
120120
});
121+
it('should handle elements without tag names', function () {
122+
const e1 = genElement(null);
123+
const arr = d.treeToArray(e1);
124+
expect(arr).to.eql([]);
125+
});
121126
it('should put the innermost element last', function () {
122127
const e1 = genElement('div', 'id1');
123128
const e2 = genElement('div', 'id2', 'a b');

0 commit comments

Comments
 (0)