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

> I was personally surprised by the removal of reference styling, i.e. the use of the fragment's context to determine what it'd look like [...] In the case a user wanted a kind of template for reuse-with-tweaks

As a quick and easy tweak I can see how this might be missed, I was thinking more in terms of what is possible in absolutes... Reference context dependence can be avoided with some re-thinking of CSS. However utilizing context-based styling is very powerful because you can make things automatically look entirely (or slightly) different, with minimal CSS - or at least you could, but now it would require much duplication with the same CSS, not merely re-arranging it.

> It seems it's only my recollection though that, at least a few years ago, mixing styles was what was flaky — that reference and instance styling could be used somewhat reliably if relatively independently

You may be correct for more recent years, I remember needing to avoid it for older browsers originally though. Relying on the merging of those cascades is definitely the inconsistent part though.

> This kind of exact re-presentation does not seem possible to achieve at all in SVG2. Absent a way to control for version, there's no way implement alternative CSS or JS to get cross platform consistency either. So this feature is presently dead even though SVG2 support is minimal. At least instance styling can be achieved, albeit with a new high-friction approach (though it is still breaking of course).

In case you missed it, I wrote an unpollyfill (i.e a pollyfill for SVG v1) that restores instance-context styling:

https://github.com/ThomasBrierley/svg2use-unpolyfill

I wrote this with care to be as performant and minimal as possible, it is well tested and in use throughout all of the products I help develop (in fact i've skipped adding it to application development and injected this straight into index pages server side inside of a condition for firefox useragents).

However I skipped the reference context styling because of the extra complexity and performance penalties it would incur. It would be quite possible to extend this pollyfill with that support, though keeping it dynamic AND performant may be challenging... using `Element.currentStyle` would be the inroad to that support, although that is non-standard, but supported by FireFox which is the only place this issue currently exists (I do wonder sometimes if it will ever go beyond FireFox, it's been 4 years now).

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

Received on Tuesday, 9 June 2020 00:00:30 UTC