Skip to content

Conversation

@tt-a1i
Copy link
Contributor

@tt-a1i tt-a1i commented Dec 9, 2025

Summary

During Next.js page transitions, elements may be destroyed and element.tagName can become undefined, causing TypeError: Cannot read properties of undefined (reading 'toLowerCase').

This PR adds defensive checks to 4 places where tagName.toLowerCase() was called without protection:

  • context.ts:141 - getHTMLPreview function
  • context.ts:183 - formatElements helper
  • agent.ts:180 - element validation check
  • is-selection-inside-editable-element.ts:2 - isEditableElement function (called from selectionchange event)

Changes

- const tagName = element.tagName.toLowerCase();
+ const tagName = (element.tagName || "").toLowerCase();

Related

Fixes #44

@vercel
Copy link

vercel bot commented Dec 9, 2025

@tt-a1i is attempting to deploy a commit to the Million Team on Vercel.

A member of the Team first needs to authorize it.

During Next.js page transitions, elements may be destroyed and
element.tagName can become undefined, causing TypeError.

Fixes aidenybai#44
@tt-a1i tt-a1i force-pushed the fix/tolowercase-undefined branch from df22f0c to aedc740 Compare December 9, 2025 01:59
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.

Error log 'toLowerCase' when next pages router changed

1 participant