Remove requirement for src or srcset attribute on img element#12627
Remove requirement for src or srcset attribute on img element#12627johannesodland wants to merge 1 commit into
Conversation
|
|
||
| <p>At least one of the <code data-x="attr-img-src">src</code> and <code | ||
| data-x="attr-img-srcset">srcset</code> attributes must be present.</p> | ||
|
|
There was a problem hiding this comment.
If an img element is not a child of a picture element, aren't the src or srcset attributes required on that img element?
Therefore, simply deleting this sentence is not appropriate.
There was a problem hiding this comment.
I'm happy to add this, but I was looking to the video and audio elements and could not find a similar requirement. If the img element is a child of a picture element, do we need to validate the source elements?
There was a problem hiding this comment.
I updated the text to depend on whether or not the parent element is a picture element:
If the
imgelement's parent is not apictureelement, then at least one of thesrcandsrcsetattributes must be present.
Do you think that is sufficient?
It is still very much possible to have markup like this:
<picture>
<img alt="some alt text">
</picture>If we additionally require a source element, then its still possible to write markup like this:
<picture>
<source media="print" srcset="…">
<img alt="some alt text">
</picture>|
The following sentence should be added.
Ref:
|
886b3c0 to
11a5342
Compare
Solves: whatwg#11313 The current spec requires an img or an alt attribute on the img element, even though the source can be provided through source elements. This PR removes that requirement to ease authoring of valid img elements. Browsers already handle img elements without src and srcset attributes. There's an existing web platform test that relies on this behavior: https://github.com/web-platform-tests/wpt/blob/5b9051943bd631d20f1f1681778d655cbfbeceb8/html/semantics/embedded-content/the-img-element/responsive-image-select-print.html#L19 A PR for a more specific test has been added here: web-platform-tests/wpt#60621 A separate PR will be filed to update the complete getter steps under the corresponding issue: https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-complete
11a5342 to
d76ee3c
Compare
I added the sentence. This requirement should probably have been added previously when removing the requirement for the |
Solves: #11313
The current spec requires an img or an alt attribute on the img element, even though the source can be provided through source elements. This PR removes that requirement to ease authoring of valid img elements.
Browsers already handle img elements without src and srcset attributes. There's an existing web platform test that relies on this behavior: https://github.com/web-platform-tests/wpt/blob/5b9051943bd631d20f1f1681778d655cbfbeceb8/html/semantics/embedded-content/the-img-element/responsive-image-select-print.html#L19
A PR for a more specific test has been added here: web-platform-tests/wpt#60621
A separate PR will be filed to update the complete getter steps under the corresponding issue: https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-complete
selecting an image sourcewhen src or srcset are missing from img but exist on source. web-platform-tests/wpt#60621(See WHATWG Working Mode: Changes for more details.)
/embedded-content.html ( diff )