Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/autocapture-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ export function getDirectAndNestedSpanText(target: Element): string {
*/
export function getNestedSpanText(target: Element): string {
let text = ''
if (target.children?.length > 0) {
if (target && target.children?.length > 0) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it's a nice balance between the legible version and the paranoid version.

It's a really tricky balance. If we never trust TS then what's the point of using it, but it's JS that runs in the browser and we know that'll do the stupidest thing at least 50% of the time 🤣

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

💯

for (const child of target.children) {
if (child && child.nodeType === 1 && child.tagName.toLowerCase() === 'span') {
const spanText = getSafeText(child)
Expand Down