[feat] Add frontend for executing JS in st.html#12918
Merged
sfc-gh-bnisco merged 2 commits intodevelopfrom Nov 6, 2025
Merged
Conversation
Contributor
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Collaborator
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Contributor
✅ PR preview is ready!
|
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the HTML component to support unsafe JavaScript execution through a new unsafeAllowJavascript flag. The implementation splits HTML rendering into two paths: sanitized HTML (existing behavior) and HTML with JavaScript execution enabled (new behavior).
Key changes:
- Extracted DOMPurify hooks into a shared
dompurifyHooks.tsmodule for reuse - Split the main
Htmlcomponent into three specialized components:SanitizedHtml,HtmlWithJs, andHtmlContainer - Added comprehensive test coverage for both sanitization and JavaScript execution paths
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/lib/src/test_util.tsx | Changed mock function from vi.fn() to empty arrow function for setFullScreen |
| frontend/lib/src/components/elements/Html/dompurifyHooks.ts | Extracted DOMPurify hooks for target="_blank" link handling into a centralized module |
| frontend/lib/src/components/elements/Html/SanitizedHtml.tsx | Created new component for sanitized HTML rendering without JavaScript |
| frontend/lib/src/components/elements/Html/HtmlWithJs.tsx | Created new component that sanitizes but preserves and executes script tags |
| frontend/lib/src/components/elements/Html/HtmlContainer.tsx | Created shared container component wrapping StyledHtml with common props |
| frontend/lib/src/components/elements/Html/Html.tsx | Refactored to route to either SanitizedHtml or HtmlWithJs based on unsafeAllowJavascript flag |
| frontend/lib/src/components/elements/Html/Html.test.tsx | Comprehensive test suite covering both sanitization and JavaScript execution paths |
e54803e to
461b031
Compare
9ad33c4 to
0ade7e7
Compare
461b031 to
0aefd4e
Compare
0aefd4e to
a6334cb
Compare
0ade7e7 to
d276838
Compare
sfc-gh-lwilby
approved these changes
Nov 6, 2025
d276838 to
89d39c5
Compare
a6334cb to
a806dd8
Compare
Collaborator
Author
Merge activity
|
a806dd8 to
622ffb2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Describe your changes
Refactored the HTML component to properly handle JavaScript execution when
unsafeAllowJavascriptis enabled. The implementation now:SanitizedHtmlandHtmlWithJsTesting Plan
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.