From 1bda0a6e2ee83fb7f3e7a6291992a9105f718d9a Mon Sep 17 00:00:00 2001 From: Joe McGill Date: Wed, 20 Jul 2016 14:37:24 +0000 Subject: [PATCH] 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 --- src/wp-includes/js/shortcode.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/wp-includes/js/shortcode.js b/src/wp-includes/js/shortcode.js index 7028f6a8bd..79423eecff 100644 --- a/src/wp-includes/js/shortcode.js +++ b/src/wp-includes/js/shortcode.js @@ -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';