Adding svg() helper and improved component error reporting#107
Open
AhnafCodes wants to merge 2 commits intot-strings:mainfrom
Open
Adding svg() helper and improved component error reporting#107AhnafCodes wants to merge 2 commits intot-strings:mainfrom
svg() helper and improved component error reporting#107AhnafCodes wants to merge 2 commits intot-strings:mainfrom
Conversation
- `tdom/parser.py`: Implement SVG context detection and case correction for tags and attributes using `SVG_TAG_FIX` and `SVG_CASE_FIX`. Update `TemplateParser` to accept `svg_context` and track `_svg_depth`. - `tdom/processor.py`: Add `svg()` function for parsing SVG fragments without a root `<svg>` element. Update `_invoke_component` to add context notes to `TypeError`s (e.g. missing arguments), identifying the component name. - `tdom/utils.py`: Update `CachableTemplate` to include `svg_context` in equality and hash checks to differentiate HTML and SVG templates in the cache. - Add tests for SVG case handling and composition.
davepeck
requested changes
Feb 25, 2026
Contributor
davepeck
left a comment
There was a problem hiding this comment.
@AhnafCodes this looks good to me, thank you so much. Let's make sure CI fully passes and make the one minor change, but I think we should merge this.
…of changing private _svg_depth
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.
tdom/parser.py: Implement SVG context detection and case correction for tags and attributes usingSVG_TAG_FIXandSVG_CASE_FIX. UpdateTemplateParserto acceptsvg_contextand track_svg_depth.tdom/processor.py: Addedsvg()function for parsing SVG fragments without a root<svg>element.tdom/utils.py: UpdatedCachableTemplateto includesvg_contextin equality and hash checks to differentiate HTML and SVG templates in the cache.Added tests for SVG case handling and composition.
Updated
_invoke_componentto add context notes toTypeErrors (e.g. missing arguments), identifying the component name.