Re: [svgwg] SVG2 spec means elements within a <use> tag can not be targeted for styling

Thanks for reopening.  It's likely that my concern does mix different issues and apologies if my terminology isn't quite right, but @dholbert summarizes my issue well:  How can you target a subelement within an SVG clone for styling?

Another use case to help add context to the problem: building a game in which the characters and opponents are complex SVG (let's say a couple pages of path elements per character).  These characters have N different visual attributes (health, strength, uniform color, etc) that vary each with M different potential values.  The values change depending on the scenario and the state of the character at any time.  You have P opponents in a battle whose N x M values are changing individually.

In SVG 1, the implementation is easy.  You create one character, clone it P times, and then add / remove classes to the clones to configure the N x M values dynamically.

In SVG 2, the implementation is basically "sprites".  You have to create N x M versions to clone at the outset and then dynamically and somehow seamlessly swap in different versions to show different states.  This is largely impossible and unwieldy for any interesting values of N and M.  So, instead, you end up creating P elements, each with the two pages of code repeated, so you can style them dynamically.  That is, you can either have the value of `<use>` (repeating structure) or the value of CSS (styling elements individually), but not both at the same time.

-- 
GitHub Notification of comment by markofca
Please view or discuss this issue at https://github.com/w3c/svgwg/issues/367#issuecomment-350497332 using your GitHub account

Received on Saturday, 9 December 2017 18:46:33 UTC