Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error handling for sizes attribute #113

Closed
zcorpan opened this issue Feb 21, 2014 · 4 comments · Fixed by #122
Closed

Error handling for sizes attribute #113

zcorpan opened this issue Feb 21, 2014 · 4 comments · Fixed by #122

Comments

@zcorpan
Copy link

zcorpan commented Feb 21, 2014

#97 is about srcset, let's talk about sizes.

Pondering about it a bit, I think it makes more sense to use CSS rules for sizes than it does for srcset. sizes can contain media queries, and media="" already uses CSS rules in HTML. Also it's supposed to support things like calc or other things CSS supports in place of a <length>.

Right now, if sizes fails to parse, the attribute is ignored. Is that what we want?

Take this example from the spec:

<picture>
  <source sizes="(max-width: 30em) 100%, (max-width: 50em) 50%, calc(33% - 100px)"
          srcset="pic100.jpg 100w, pic200.jpg 200w, pic400.jpg 400w,
                  pic800.jpg 800w, pic1600.jpg 1600w, pic3200.jpg 3200w">
  <img src="pic400.jpg" alt="The president giving an award.">
</picture>

If the UA doesn't support calc, then it acts as if sizes was absent. Do we instead want to act as if sizes="(max-width: 30em) 100%, (max-width: 50em) 50%" (so that the browser at least does the right thing for 2 of the 3 layouts)? Or skip the whole source (so the author can specify a fallback source without using calc)? Something else?

@yoavweiss
Copy link
Member

I think that skipping the whole source, so that a fallback sizes can be defined is better for future compat. In the "just use <hat you understand" option, authors cannot define a fallback for older browsers.

OTOH, if the author haven't defined a fallback source, older browsers will get a significantly worse experience with this option.

I guess it boils down to what is more probable. Do we think that authors are likely to define fallback content?

@zcorpan
Copy link
Author

zcorpan commented Feb 24, 2014

Realistically speaking, it seems unlikely that authors will include a fallback source. It seems more probable that they will avoid using calc until it is supported or use a polyfill. From that perspective it seems unnecessary to tweak the behavior.

@zcorpan
Copy link
Author

zcorpan commented Feb 25, 2014

@tabatkins in #86 says that invalid sizes will result in the source being skipped (although that's not what the current spec says).

@tabatkins
Copy link

Hm, that's a problem. It should skip things. I'll fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants