Skip to content

fix: add runtime instanceof Node guard in click outside handler#6259

Open
quentin-adzap wants to merge 1 commit intoHacker0x01:mainfrom
quentin-adzap:main
Open

fix: add runtime instanceof Node guard in click outside handler#6259
quentin-adzap wants to merge 1 commit intoHacker0x01:mainfrom
quentin-adzap:main

Conversation

@quentin-adzap
Copy link
Copy Markdown


name: Pull Request
about: add runtime instanceof Node guard in click outside handler
title: ""
labels: ""
assignees: ""

Description

Linked issue: #(issue number)

Problem
When the composedPath() lookup doesn't find a Node, target falls back to
event.target which is typed as EventTarget | null. The existing code used a
TypeScript as Node cast, but this is erased at compile time — so
Node.contains() in dist/index.js receives an unguarded EventTarget.

Changes
This adds an explicit target instanceof Node runtime check before calling
.contains(), which also removes the need for the type cast.

Screenshots

To reviewers

Verified the compiled dist/index.js output includes the instanceof Node guard

Contribution checklist

  • I have followed the contributing guidelines.
  • I have added sufficient test coverage for my changes.
  • I have formatted my code with Prettier and checked for linting issues with ESLint for code readability.

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.

1 participant