airframe
airframe copied to clipboard
rx-html: Resolve naming conflicts between HTML and SVG attributes
Summary
This PR implements issue #3953 to resolve naming conflicts between HTML and SVG attributes in the rx-html library, enabling seamless integration of both attribute sets.
Problem
Previously, developers couldn't easily import both HTML and SVG tags/attributes together using import wvlet.airframe.rx.html.all.* due to naming conflicts for common attributes like style, class, title, etc.
Solution
- Created a new
UnifiedTagstrait that intelligently handles conflicts - Added
unifiedAllobject that can be imported to use both HTML and SVG together - SVG conflicting attributes are prefixed with 'svg' (e.g.,
svgStyle,svgClass) - Uses Scala 3's
exportstatements for selective imports
Key Changes
- Fixed SVG namespace handling - Enabled proper SVG namespace for all attributes
- Created conflict resolution mechanism - Prefixed SVG versions for conflicts
-
Added unified import - New
unifiedAllobject for combined usage - Comprehensive tests - Added test suite verifying the functionality
- Documentation - Created README with examples and conflict mapping
Usage Example
import wvlet.airframe.rx.html.unifiedAll.*
div(
cls -> "container", // HTML class
style -> "padding: 20px;", // HTML style
svg(
svgWidth -> "400", // SVG width
svgHeight -> "300", // SVG height
svgClass -> "chart", // SVG class
svgStyle -> "fill: blue;", // SVG style
circle(cx -> "50", cy -> "50", r -> "40")
)
)
Test plan
- [x] Added UnifiedTagsTest.scala with comprehensive tests
- [x] All existing tests pass
- [x] Verified proper namespace assignment for attributes
- [x] Tested combined HTML/SVG usage scenarios
🤖 Generated with Claude Code