Re: src overriding href overriding xlink:href

On Thu, Apr 16, 2015 at 8:44 PM, Amelia Bellamy-Royds
<amelia.bellamy.royds@gmail.com> wrote:
> Elaboration:  http://codepen.io/AmeliaBR/details/wBZrog
>
> The basic structure is, within inline SVG, create an `<image>` element that
> has a `src` attribute pointing to your fallback content, but an invalid
> `xlink:href` attribute.  Old browsers see a  non-standard HTML `<img>`,
> modern browsers see an empty SVG `<image>`, everyone is happy.
>
> It's probably not quite as common a fallback technique as using JS (either
> directly or by using Modernizr to set CSS classes), but it is more robust.
> And it is used.  It might be used even more frequently soon: the above demo
> was created for a blog post on SVG Fallbacks, which will be published in the
> near future on CSS-Tricks.
>
> If suddenly `src` gained meaning in SVG, and especially if it took
> precedence over `xlink:href`, these SVGs would be downloading fallback
> images and painting them overtop of the SVG content.

Alternative proposal in this vein: skip src, just add srcset.  SVG
needs to adopt srcset anyway for all the things that can reference
bitmap images, and the use of srcset on <img> isn't as common as src,
so it's less likely to run afoul of this kind of hack.

(Our efforts to just intermix HTML and SVG mean that we should be able
to use the <html:picture> element directly, for more complicated
stuff, but we still need to explicitly add srcset to the relevant SVG
elements.)

~TJ

Received on Friday, 17 April 2015 20:22:44 UTC