From 78e54c2e727d3ceff40d9b0a255c86459ef6e8b3 Mon Sep 17 00:00:00 2001 From: David Somers <126989+jalada@users.noreply.github.com> Date: Tue, 14 Oct 2025 16:45:53 +0100 Subject: [PATCH 1/2] Handle null nextDescription in describeElement Co-authored-by: Lucas Halfpenny --- src/browser/domUtility.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/browser/domUtility.js b/src/browser/domUtility.js index 7c1bef8c..b231a17c 100644 --- a/src/browser/domUtility.js +++ b/src/browser/domUtility.js @@ -34,7 +34,7 @@ function treeToArray(elem) { var nextDescription; for (var height = 0; elem && height < MAX_HEIGHT; height++) { nextDescription = describeElement(elem); - if (nextDescription.tagName === 'html') { + if (!nextDescription || nextDescription.tagName === 'html') { break; } out.unshift(nextDescription); From f2fd276b89b1d21b0bdfae1207cf8f21dde09a68 Mon Sep 17 00:00:00 2001 From: jalada <126989+jalada@users.noreply.github.com> Date: Tue, 14 Oct 2025 16:57:41 +0100 Subject: [PATCH 2/2] Add a regression test for genElement handling elements with no tagName Co-authored-by: Lucas Halfpenny --- test/browser.domUtility.test.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/browser.domUtility.test.js b/test/browser.domUtility.test.js index d7154578..956673f9 100644 --- a/test/browser.domUtility.test.js +++ b/test/browser.domUtility.test.js @@ -109,6 +109,11 @@ describe('treeToArray', function () { var arr = d.treeToArray(e1); expect(arr.length).to.eql(5); }); + it('should handle elements without tag names', function () { + var e1 = genElement(null); + var arr = d.treeToArray(e1); + expect(arr).to.eql([]); + }); it('should put the innermost element last', function () { var e1 = genElement('div', 'id1'); var e2 = genElement('div', 'id2', 'a b');