[whatwg] The src-N proposal

Tab Atkins Jr. jackalmage at gmail.com
Tue Nov 19 14:22:01 PST 2013

On Tue, Nov 19, 2013 at 2:07 PM, Simon Pieters <simonp at opera.com> wrote:
> So:
> <picture>
>  <source ...>
>  <source ...>
>  <img src="fallback" alt="...">
> </picture>
> The selection algorithm would only consider <source> elements that are
> previous siblings of the <img> if the parent is a <picture> element, and
> would be called in place of the current 'process the image candidates' in
> the spec (called from 'update the image data'). 'Update the image data' gets
> run when an img element is created, has its src or crossorigin (or srcset if
> we still want that on img) attributes changed/set/removed, is inserted or
> removed from its parent, when <source> is inserted to a <picture> as a
> previous sibling, or a <source> that is a previous sibling is removed from
> <picture>, or when a <source> that is a previous sibling and is in <picture>
> has its src or srcset (or whatever attributes we want to use on <source>)
> attributes changed/set/removed. 'Update the image data' aborts if the
> parser-created flag is set. When img is inserted to the document, if the
> parser-created flag is set, the flag is first unset and then 'update the
> image data' is run but without the await a stable state step.

+1.  I'm totally fine with this, if the people who disliked multiple
attrs are okay with multiple elements.

We can still handle all the things that src-N did, without the need
for such compact microsyntaxes, too:

1. Art direction is handled by <source media>.
2. Multiple densities is handled by a list of url/density pairs in <source src>.
3. Variable-size images can be handled with a <picture sizes>
attribute, and a list of url/size pairs in <source src>.

For the last, since we're not trying to squeeze everything into a
single attributes, we can let the sizes='' attribute breath a bit, and
just take a list of MQ/size pairs.  Using a url/size pair in src=''
would be invalid if sizes='' wasn't specified.


More information about the whatwg mailing list