Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace innerHtml with insertRule #444

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

22subikim
Copy link

@22subikim 22subikim commented Jan 14, 2025

The use of .innerHTML causes issues for hosts that have opted in to Trusted Types. Because .innerHTML can act as a vector for DOM-XSS attacks, websites might lock it down with Trusted Types, causing the specific line to throw a runtime error.

In the case of this specific library, the .innerHTML call could just as easily be replaced with inserting a CSS rule, as follows:

styleElement.sheet?.insertRule(`*{cursor: ${style}!important;}`)

Note that to satisfy TypeScript, null-coalescing is added to the .sheet access. However, when a style element is attached to the DOM, that .sheet property should never be undefined.

Copy link

vercel bot commented Jan 14, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-resizable-panels ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 14, 2025 3:54pm

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