Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Bug 1237139 - Set the aria-valuetext on value pickerS container, not …
Browse files Browse the repository at this point in the history
…option
  • Loading branch information
Zibi Braniecki committed Jan 8, 2016
1 parent ff0ef30 commit 8c87b98
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
16 changes: 12 additions & 4 deletions apps/system/js/value_selector/value_picker.js
Expand Up @@ -142,11 +142,19 @@ var ValuePicker = (function() {
this.element.style.transform = 'translateY(' + this._top + 'px)';
this.container.setAttribute('aria-valuenow', index);

if (this._optionsL10n[index] &&
this._optionsL10n[index].hasOwnProperty('raw')) {
this.container.setAttribute('aria-valuetext',
this._optionsL10n[index].raw);
var valPromise;
if (typeof this._optionsL10n[index] === 'string') {
valPromise = navigator.mozL10n.formatValue(this._optionsL10n[index]);
} else if (this._optionsL10n[index].hasOwnProperty('id')) {
valPromise = navigator.mozL10n.formatValue(
this._optionsL10n[index].id, this._optionsL10n[index].args);
} else {
valPromise = Promise.resolve(this._optionsL10n[index].raw);
}

valPromise.then(val => {
this.container.setAttribute('aria-valuetext', val);
});
}
};

Expand Down
14 changes: 13 additions & 1 deletion apps/system/test/unit/value_picker_test.js
@@ -1,9 +1,20 @@
/* global ValuePicker */
/* global ValuePicker, MockL10n */
'use strict';

requireApp('system/js/value_selector/value_picker.js');
require('/shared/test/unit/mocks/mock_l10n.js');

suite('value selector/value picker', function() {
var realL10n;

setup(function() {
realL10n = navigator.mozL10n;
navigator.mozL10n = MockL10n;
});

teardown(function() {
navigator.mozL10n = realL10n;
});

suite('Month value picker', function() {
var subject, dom, unitStyle;
Expand Down Expand Up @@ -102,6 +113,7 @@ suite('value selector/value picker', function() {
optionsL10n: ['AM', 'PM'],
className: 'picker-unit'
};

subject = new ValuePicker(dom, unitStyle);
});

Expand Down
2 changes: 0 additions & 2 deletions shared/locales/date/date.en-US.properties
Expand Up @@ -238,9 +238,7 @@ listSeparator_middle =,\u0020

# Localize dayperiod (am/pm in en-US) tokens
time_am = AM
time_am.ariaValueText = AM
time_pm = PM
time_pm.ariaValueText = PM

# Duration Format patterns for:
# hh:mm:ss.SS => Hour:Minute:Second.Millisecond
Expand Down

0 comments on commit 8c87b98

Please sign in to comment.