feat(web): browser environment assertion#707
Open
hejsztynx wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an explicit runtime assertion that EnrichedText and EnrichedTextInput only run in a real browser/DOM environment, to avoid SSR crashes and provide a clearer error, and updates web docs accordingly.
Changes:
- Introduce
assertBrowserEnvironment()and invoke it at the start ofEnrichedTextandEnrichedTextInput. - Remove silent
DOMParser-missing fallbacks from web HTML normalization helpers. - Document that the web components are client-only (SSR not supported).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/web/normalization/prepareHtmlForWeb.ts | Removes silent non-DOM fallback; relies on browser-only execution path. |
| src/web/normalization/htmlNormalizer.ts | Removes silent non-DOM fallback before using DOMParser. |
| src/web/EnrichedTextInput.tsx | Asserts browser environment before running component logic. |
| src/web/EnrichedText.tsx | Asserts browser environment before running component logic. |
| src/web/assertBrowserEnvironment.ts | Adds shared DOM availability assertion with a clearer error message. |
| docs/WEB.md | Documents client-only rendering requirement (no SSR). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
hejsztynx
marked this pull request as draft
July 17, 2026 08:58
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
src/web/normalization/prepareHtmlForWeb.ts:11
prepareHtmlForWebnow relies onDOMParser(andNode.ELEMENT_NODE) without any guard. In non-DOM environments this will throw a low-levelReferenceError(DOMParser is not defined) instead of a library-specific, actionable error.
if (useHtmlNormalizer) {
html = normalizeHtml(html);
}
const parser = new DOMParser();
hejsztynx
marked this pull request as ready for review
July 17, 2026 10:03
Collaborator
|
|
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.
Summary
Both components
EnrichedTextandEnrichedTextInputare using DOM -DOMPurify,DOMParser,TipTap. An attempt of rendering them in a non-browser environment, e.g. in SSR applications, would result in a crash. OnlyDOMParseravailability check was present, but it was silent. Now we check for the browser environment before any other component logic and throw a proper error. Documentation was also updated, to explicitly point the client-only nature of the components.Compatibility
Checklist