Media: Ensure empty alt
attributes are set to blank strings.
This is a follow up to [38065] to ensure that `wp.html.string()` always converts empty `alt` attributes to `alt=""` rather than returning HTML using empty attribute notation, like `alt`. This allows screen readers to ignore images with empty `alt` attributes, rather than reading out the URL string. Additionally this completely removes the logic in `wp.html.string()` for converting blank attributes to empty attribute notation since empty attribute notation is generally meant to denote a boolean value, e.g., `checked` == `checked="checked"`, which doesn't apply in this context because boolean attributes must be omitted in order to represent a `false` value. See: https://www.w3.org/TR/html5/infrastructure.html#boolean-attributes Props adamsilverstein, afineman, joemcgill. Fixes #36735. git-svn-id: https://develop.svn.wordpress.org/trunk@38116 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
e284dafbc7
commit
1bda0a6e2e
@ -326,11 +326,6 @@ window.wp = window.wp || {};
|
||||
_.each( options.attrs, function( value, attr ) {
|
||||
text += ' ' + attr;
|
||||
|
||||
// Use empty attribute notation where possible.
|
||||
if ( '' === value ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Convert boolean values to strings.
|
||||
if ( _.isBoolean( value ) ) {
|
||||
value = value ? 'true' : 'false';
|
||||
|
Loading…
Reference in New Issue
Block a user