Fix content loss by transforming legacy div and h1 tags#15235
Merged
DanielCliftonGuardian merged 1 commit intomainfrom Feb 3, 2026
Merged
Fix content loss by transforming legacy div and h1 tags#15235DanielCliftonGuardian merged 1 commit intomainfrom
DanielCliftonGuardian merged 1 commit intomainfrom
Conversation
|
Hello 👋! When you're ready to run Chromatic, please apply the You will need to reapply the label each time you want to run Chromatic. |
marjisound
reviewed
Jan 28, 2026
| }; | ||
| }, | ||
| div: 'p', | ||
| h1: 'h2', |
Contributor
There was a problem hiding this comment.
Interesting, what error did you find in the logs that could be fixed by this change? And what is the reason for making div to be p and h1 to become h2? Why couldn't we keep them as div and h1
Contributor
Author
There was a problem hiding this comment.
- This generates around 2000 warns a day see logs . Because we return null on unknown tags, we discard all nested children. In old sports blogs, DIV wrappers cause entire team lineups to be deleted from the page.
- We transform H1 to H2 so that we maintain the best practice of only one H1 per page.
- Transforming DIV to P allows us to inherit standard styling. This is much cleaner than adding redundant switch cases and CSS to handle legacy elements.
alexduf
approved these changes
Feb 3, 2026
Contributor
alexduf
left a comment
There was a problem hiding this comment.
Following yesterday's conversation, it makes sense to me
|
Seen on PROD (merged by @DanielCliftonGuardian 7 minutes and 57 seconds ago) Please check your changes! |
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.
What does this change?
TextBlockComponentcurrently returnsnullwhen it encounters unknown tags like<div>(common in 2013/14 legacy content) or<h1>. This causes content loss because recursion stops and all child elements are discarded. This PR updatessanitiserOptionsto transformdivtopandh1toh2before they reach the renderer.Why?
Part of guardian/frontend#28496