airframe icon indicating copy to clipboard operation
airframe copied to clipboard

rx-html: Resolve naming conflicts between HTML and SVG attributes

Open xerial opened this issue 7 months ago • 0 comments

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 UnifiedTags trait that intelligently handles conflicts
  • Added unifiedAll object 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 export statements for selective imports

Key Changes

  1. Fixed SVG namespace handling - Enabled proper SVG namespace for all attributes
  2. Created conflict resolution mechanism - Prefixed SVG versions for conflicts
  3. Added unified import - New unifiedAll object for combined usage
  4. Comprehensive tests - Added test suite verifying the functionality
  5. 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

xerial avatar Jul 19 '25 15:07 xerial