blackears / svgSalamander

158 stars 57 forks source link

Properly implement <tspan> #79

Closed weisJ closed 3 years ago

weisJ commented 3 years ago

Seeing in #71 that <tspan> isn't properly implemented I have taken the liberty to do this.

Previously spans were using the attributes of the parent tag. They also couldn't be children of other tags.

The element now stores a list of text segments which are rendered in order to ensure correct z-ordering. This allows elements to contain other spans itself. The element now simply inherits from and performs the additional transformation defined by 'text-anchor'.

The Text element should be API compatible with previous versions. Fot the Tspan tag however I wasn't sure how to deal with the setText method. If there is no child then it can behave as before and simply overwrite the contained text. If child spans exists I'm not so sure what should happen. For now I have removed the method, though intend to add it back in once it is clear how it should behave.

weisJ commented 3 years ago

I’ll try to address #42 too.