Simplified source selection algorithm

In response to Simon Pieters' criticism that <source> selection algorithm  
is too complex[1], I've drafted a simpler one:

https://github.com/ResponsiveImagesCG/picture-element/issues/62#issuecomment-24479164

Simon finds this algorithm acceptable[2]. I'd like to hear your opinion  
whether such solution is OK.


  - Dependency on Media Element and <video>-like algorithm is gone. There's  
no networkState property.

  - The algorithm picks the first <source> that matches. Matching is done  
based on media and type attributes.

  - I haven't written that explicitly on github, but selected <source  
src/srcset> is interpreted pretty much like copying of its attributes to  
<img src/srcset>.

  - Browser will re-evaluate sources whenever conditions change (so if  
device is rotated or window is resized a different source may be picked,  
and different image may be loaded).

  - Choice is made asynchronously and atomically from JavaScript's  
perspective (i.e. messing with <source> DOM elements won't change the  
selected source until next event loop tick).

  - If you use <source media> with media query that browser cannot evaluate  
immediately (e.g. min-width: in an iframe that has no layout yet) browser  
may delay fetching of the image until CSS is loaded.

-- 
regards, Kornel

[1] http://lists.w3.org/Archives/Public/public-html/2013Sep/0137.html
[2] http://lists.w3.org/Archives/Public/public-html/2013Sep/0185.html

Received on Monday, 16 September 2013 22:53:53 UTC