Skip to content

Conversation

@jalada
Copy link

@jalada jalada commented Oct 14, 2025

Description of the change

Handle when describeElement returns null e.g. if the element isn't something that has a tag name etc.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Maintenance
  • New release

Checklists

Development

  • Lint rules pass locally
  • The code changed/added as part of this pull request has been covered with tests
  • All tests related to the changed code pass in development

Code review

  • This pull request has a descriptive title and information useful to a reviewer. There may be a screenshot or screencast attached
  • "Ready for review" label attached to the PR and reviewers assigned
  • Issue from task tracker has a link to this pull request
  • Changes have been reviewed by at least one other engineer

for (var height = 0; elem && height < MAX_HEIGHT; height++) {
nextDescription = describeElement(elem);
if (nextDescription.tagName === 'html') {
if (!nextDescription || nextDescription.tagName === 'html') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!nextDescription || nextDescription.tagName === 'html') {
if (nextDescription == null || nextDescription.tagName?.toLowerCase() === 'html') {

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need the ? if it's null? The code in describeElement looks like it reliably sets a tagname if not. It also already calls toLowerCase() when setting it.

Just being extra defensive?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants