WordPress.org

Make WordPress Core

Changeset 38116


Ignore:
Timestamp:
07/20/16 14:37:24 (17 months ago)
Author:
joemcgill
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/shortcode.js

    r34933 r38116  
    327327                text += ' ' + attr; 
    328328 
    329                 // Use empty attribute notation where possible. 
    330                 if ( '' === value ) { 
    331                     return; 
    332                 } 
    333  
    334329                // Convert boolean values to strings. 
    335330                if ( _.isBoolean( value ) ) { 
Note: See TracChangeset for help on using the changeset viewer.