Skip to content

Commit

Permalink
issue/2553 Added a11y_alt_text helper (#2554)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverfoster authored Oct 25, 2019
1 parent aae110d commit a92c7ff
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions js/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,18 @@ define([
a11y_attrs_tabbable: function() {
Adapt.a11y.log.deprecated('a11y_attrs_tabbable should not be used. tabbable elements should be natively tabbable.');
return new Handlebars.SafeString(' role="region" tabindex="0" ');
},

/**
* Produce display text with alternative screen reader version.
* @param {string} visible Text that will be displayed on screen
* @param {string} alternatives Text that will be read by the screen reader (instead of what's displayed on screen)
* @example {{a11y_alt_text '$5bn' 'five billion dollars'}} or {{a11y_alt_text 'Here are some bits to read' 'There are' _items.length 'items to read'}}
*/
a11y_alt_text: function(visible, alternatives) {
var values = Array.prototype.slice.call(arguments, 1, -1);
values = values.filter(Boolean);
return new Handlebars.SafeString('<span aria-hidden="true">'+visible+'</span><span class="aria-label">'+values.join(' ')+'</span>');
}

};
Expand Down

0 comments on commit a92c7ff

Please sign in to comment.