Skip to content

Adding svg() helper and improved component error reporting#107

Open
AhnafCodes wants to merge 2 commits intot-strings:mainfrom
AhnafCodes:dev
Open

Adding svg() helper and improved component error reporting#107
AhnafCodes wants to merge 2 commits intot-strings:mainfrom
AhnafCodes:dev

Conversation

@AhnafCodes
Copy link

@AhnafCodes AhnafCodes commented Feb 20, 2026

  • 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: Added svg() function for parsing SVG fragments without a root <svg> element.

  • tdom/utils.py: Updated CachableTemplate to include svg_context in equality and hash checks to differentiate HTML and SVG templates in the cache.

  • Added tests for SVG case handling and composition.

  • Updated _invoke_component to add context notes to TypeErrors (e.g. missing arguments), identifying the component name.

- `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.
Copy link
Contributor

@davepeck davepeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

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.

2 participants