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

Treatment of fallback image on <img src=''> #3280

Closed
mwenge opened this issue Dec 8, 2017 · 7 comments
Closed

Treatment of fallback image on <img src=''> #3280

mwenge opened this issue Dec 8, 2017 · 7 comments
Labels
interop Implementations are not interoperable with each other topic: img

Comments

@mwenge
Copy link
Contributor

mwenge commented Dec 8, 2017

To my reading <img src=''> falls into the part of https://html.spec.whatwg.org/multipage/embedded-content.html#the-img-element that says: "If the src attribute is set and the alt attribute is not.. the user agent should display some sort of indicator that there is an image that is not being rendered".

In https://bugs.chromium.org/p/chromium/issues/detail?id=793206 we encountered interoperability issues because Blink now renders a fallback image in that case, rather then 'nothing' like other browsers.

As far as I can see Blink is following the spec here, unless src is not considered 'set' when src=''.

Have I misunderstood the meaning of 'set' in this case? And if not, should the spec be changed to allow rendering 'nothing' in this case as it is what all browsers do (apart from Blink since Chrome M63)? (Although FF is the only other browser that currently attempts to follow this part of the spec, and it seems to treat src='' as 'not set'.

@annevk annevk added topic: img interop Implementations are not interoperable with each other labels Dec 9, 2017
@domenic
Copy link
Member

domenic commented Dec 12, 2017

Your understanding of "set" is correct. This is a bit more complex though, as it appears to depend on the width/height: https://jsbin.com/foyapuz/1/edit?html,output

Note that per the normative text in https://html.spec.whatwg.org/#update-the-image-data, src="" always causes a broken image. (Instead of, e.g., fetching the contents of the base URL after resolving the empty string against the page's base URL.)

Based on the above test case appear to be several behaviors in current browsers for broken images:

  • Firefox, Chrome 62, Safari Tech Preview:
    • width/height causes broken image placeholders to always be shown
    • no width/height causes broken image placeholders to be shown unless src=""
    • Safari seems to use a different broken image placeholder for src="" than for src="asdf"
  • Edge:
    • src="" causes no placeholders to be shown; otherwise, they are shown
  • Chrome 63:
    • shows broken image placeholders always, although src="" broken images get a different placeholder than src="asdf"

So I guess we should update the spec to point toward the first option here, revert the Chrome change, and file an Edge bug? What do you think?

@annevk
Copy link
Member

annevk commented Dec 13, 2017

Note that the img loading model also disregards empty string src attributes. A clean solution here would to observe some internal state of the img element not having a "source" (determined while running "update the image data") as then we don't have to observe the empty string thing in two places.

@mwenge
Copy link
Contributor Author

mwenge commented Dec 15, 2017

Blink reverted to its previous treatment of SRC='' under the chromium bug I quoted so it would certainly be great to get the spec updated to match the preferred behaviour for the SRC='' case.

@annevk
Copy link
Member

annevk commented Dec 15, 2017

@mwenge would you be interested in writing such a change?

domenic pushed a commit that referenced this issue Jan 2, 2018
When src is an empty string (<img src='') and the alt attribute
is not set UAs currently agree that nothing should be displayed.
Update the rules to specify this behaviour.

Closes #3280.
@annevk
Copy link
Member

annevk commented Jan 3, 2018

Reopening so this feedback by @triple-underscore is considered:

Seems that, the newly added text is misplaced under the case “...the alt attribute is set to a value that isn't empty”.
(Should be placed under the case “If the src attribute is set and the alt attribute is not” ?)

@mwenge
Copy link
Contributor Author

mwenge commented Jan 3, 2018

That was dumb. :)

domenic pushed a commit that referenced this issue Jan 4, 2018
Fix commit e78f98b
which added the text to the wrong paragraph.

Closes #3280, again.
@domenic
Copy link
Member

domenic commented Jan 4, 2018

Thanks @triple-underscore!

alice pushed a commit to alice/html that referenced this issue Jan 8, 2019
When src is an empty string (<img src='') and the alt attribute
is not set UAs currently agree that nothing should be displayed.
Update the rules to specify this behaviour.

Closes whatwg#3280.
alice pushed a commit to alice/html that referenced this issue Jan 8, 2019
Fix commit e78f98b
which added the text to the wrong paragraph.

Closes whatwg#3280, again.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interop Implementations are not interoperable with each other topic: img
Development

No branches or pull requests

3 participants