Re: [whatwg] Implementation complexity with elements vs an attribute (responsive images)

On May 12, 2012, at 10:36 AM, James Graham wrote:

> 
> 
> On Sat, 12 May 2012, Mathew Marquis wrote:
> 
>> While that information may be available at the time the img tag is parsed, I don’t believe it will be available at the time of prefetching — I’m happy to research this further and report back with citations.
> 
> I am very confused about what you are claiming here. I have difficulty imagining any scheme that would make prefetching work worse with an attribute than with multiple elements. As Simon says there is a lot more that can go wrong in the multiple-element case because a single attribute can be processed atomically, but multiple elements can have all sorts of other junk between them that makes naieve processing (of a type likely to be used when prefetching) more likely to go wrong e.g.
> 
> <picture>
> <img src="foo">
> <script>document.write("</picture>")</script>
> <source src="bar">
> </picture>
> 

I think we can safely assume that any developer responsible for the above code likely won’t blame the element itself when it produces undesirable results. I assume such a pattern applies to the video and audio elements as well, and I’ve yet to see any developers declare them failures because they accidentally wrote a script that injects half a <marquee> tag in there. 

However, given a completely foreign and somewhat puzzling new syntax, I think it’s far more likely we’ll see the following:

<img src="face-600-200@1.jpeg" alt=""
        set="face-600-200@1.jpeg 600w 1x,
             face-600-200@2.jpeg 600w 2x,
             face-icon.png       200w">

Become:

<img src="face-600-200@1.jpeg" alt=""
        set="face-600-200@1.jpeg 600 1x,
             face-600-200@2.jpeg 600 2x,
             face-icon.png       200">

Or:

<img src="face-600-200@1.jpeg" alt=""
        set="face-600-200@1.jpeg, 600w 1x
             face-600-200@2.jpeeg 600w 2x,
             face-icon.png       200w">

Regardless of how gracefully the above fail by comparison to a developer _purposefully injecting a closing tag into an element_, I’m confident this is a far more likely scenario and a “spot the differences” game very few developers will be excited to play.

Received on Saturday, 12 May 2012 14:50:08 UTC