Skip to content

[BUG] SVG Line should not have some default parameters #757

@claudiu-work

Description

@claudiu-work

in FastHTML 0.12.21 in file svg.py the Line is defined with default values for stroke and stroke_width:

def Line(x1, y1, x2=0, y2=0, stroke='black', w=None, stroke_width=1, **kwargs): ...

This results that using a line with only coordinates, will also auto generate: stroke="black" stroke-width="1"
This is wrong as it overrides attributes defined in a parent tag like <g>.
Eg. this will fail to achieve the result of having red and thick lines:

G(stroke="red", stroke_width="20" )(
        Line(x1=0, y1=0, x2=100, y2=100),
        Line(x1=0, y1=0, x2=10, y2=100),
    )

Instead of desired outputs like:

<line x1="0" y1="0" x2="100" y2="100">

will generate lines that have unwanted attributes, that override the parent:

<line x1="0" y1="0" x2="100" y2="100" stroke="black" stroke-width="1">

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions