Skip to content
This repository was archived by the owner on Dec 7, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions src/js/Properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ axs.properties.getTextFromHostLanguageAttributes = function(element,
existingComputedname,
recursive) {
var computedName = existingComputedname;
if (axs.browserUtils.matchSelector(element, 'img') && element.hasAttribute('alt')) {
if (axs.browserUtils.matchSelector(element, 'img,input[type="image"]') && element.hasAttribute('alt')) {
var altValue = {};
altValue.type = 'string';
altValue.valid = true;
Expand All @@ -520,7 +520,7 @@ axs.properties.getTextFromHostLanguageAttributes = function(element,
textAlternatives['alt'] = altValue;
}

var controlsSelector = ['input:not([type="hidden"]):not([disabled])',
var controlsSelector = ['input:not([type="hidden"]):not([type="image"]):not([disabled])',
'select:not([disabled])',
'textarea:not([disabled])',
'button:not([disabled])',
Expand Down Expand Up @@ -579,18 +579,7 @@ axs.properties.getTextFromHostLanguageAttributes = function(element,
computedName = labelWrappedValue.text;
textAlternatives['labelWrapped'] = labelWrappedValue;
}
// If all else fails input of type image can fall back to its alt text
if (axs.browserUtils.matchSelector(element, 'input[type="image"]') && element.hasAttribute('alt')) {
var altValue = {};
altValue.type = 'string';
altValue.valid = true;
altValue.text = element.getAttribute('alt');
if (computedName)
altValue.unused = true;
else
computedName = altValue.text;
textAlternatives['alt'] = altValue;
}

if (!Object.keys(textAlternatives).length)
textAlternatives['noLabel'] = true;
}
Expand Down Expand Up @@ -623,7 +612,7 @@ axs.properties.getTextProperties = function(node) {

if (Object.keys(textProperties).length == 0) {
/** @type {Element} */ var element = axs.dom.asElement(node);
if (element && axs.browserUtils.matchSelector(element, 'img')) {
if (element && axs.browserUtils.matchSelector(element, 'img,input[type="image"]')) {
var altValue = {};
altValue.valid = false;
altValue.errorMessage = 'No alt value provided';
Expand Down
14 changes: 14 additions & 0 deletions test/js/properties-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,3 +285,17 @@ test('Image with no text alternative', function() {
equal('computedText' in textProperties, true, 'computedText in textProperties');
equal(textProperties.computedText, 'smile.jpg');
});

test('Input type image with no text alternative', function() {
var fixture = document.getElementById('qunit-fixture');
var input = fixture.appendChild(document.createElement('input'));
input.type = 'image';
input.src = 'smile.jpg';
var textProperties = axs.properties.getTextProperties(input);
equal('alt' in textProperties, true, 'alt in textProperties');
equal(textProperties.alt.valid, false, 'alt is not valid');
equal('filename' in textProperties, true, 'filename in textProperties');
equal(textProperties.filename.text, 'smile.jpg');
equal('computedText' in textProperties, true, 'computedText in textProperties');
equal(textProperties.computedText, 'smile.jpg');
});