[whatwg] The srcset attribute - some implementation feedback & questions

Yoav Weiss yoav at yoav.ws
Sun Sep 22 04:05:20 PDT 2013


I've recently ported the WebKit srcset implementation into Blink, and
pretty much rewrote it in the process.

I'd like to provide some feedback and ask for clarifications, in order to
improve the implementation's spec[1] compliance. Below I'll discuss the
algorithm's step and points that I'd like clarifications on.

Step 5
----------
What happens when the srcset attribute is of the form "candidate1.png,
candidate2.png 2x"?
As far as I understand it, according to the spec it results in a single
image candidate url "candidate1.png," followed by the descriptors
"candidate2.png 2x", which is probably not what the author intended.
As a note, both WebKit & Blink implementations diverge from the spec here,
by adding a "check if the URL's last char is ',' and if so, continue
without trying to parse out descriptors" step. This also enables the
implementations to ignore empty candidates such as "candidate1.png 1x, , ,
, , candidate2.png 2x".

A similar case of <img srcset="candidate1.png,candidate2.png 2x"> results
in the image candidate URL being "candidate1.png,candidate2.png". Is that
the correct behavior?
I'm not sure what should be the result here (since splitting on commas will
break data URIs), but I'm certain this will be a source of confusion for
authors.

Step 13.6
------------
What happens when one of the valid qualifier characters is followed by
other non qualifier chars? e.g.is "2xbla" a valid descriptor?

What happens when one of the valid qualifier characters is followed by
another qualifier char? e.g.is "2xwh" a valid descriptor? Does it set all
three variables to 2?

What happens to invalid descriptors? If I understand correctly, invalid
descriptors should just be ignored so that "2x 500tt bla" will results in a
density of 2, width of infinity and height of infinity.
Is that correct?

Yoav

[1]
http://www.whatwg.org/specs/web-apps/current-work/multipage/embedded-content-1.html#processing-the-image-candidates


More information about the whatwg mailing list