Skip to content

Commit

Permalink
select: collect aria-owns ids in core templates
Browse files Browse the repository at this point in the history
  • Loading branch information
aristov committed Sep 29, 2015
1 parent f45d326 commit 3fdb0fb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 1 addition & 3 deletions common.blocks/select/__button/select__button.bemhtml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ block('select').elem('button')(
},
attrs : {
role : 'listbox',
'aria-owns' : select.options.map(function(option) {
return option.id;
}).join(' '),
'aria-owns' : this._optionsIds.join(' '),
'aria-multiselectable' : mods.mode === 'check'? 'true' : undefined,
'aria-labelledby' : this._selectTextId
},
Expand Down
4 changes: 1 addition & 3 deletions common.blocks/select/__button/select__button.bh.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ module.exports = function(bh) {
id : select.id,
attrs : {
role : 'listbox',
'aria-owns' : select.options.map(function(option) {
return option.id;
}).join(' '),
'aria-owns' : ctx.tParam('optionIds').join(' '),
'aria-multiselectable' : mods.mode === 'check'? 'true' : null,
'aria-labelledby' : selectTextId
},
Expand Down
6 changes: 4 additions & 2 deletions common.blocks/select/select.bemhtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ block('select')(
isValDef = typeof ctx.val !== 'undefined',
isModeCheck = this.mods.mode === 'check',
firstOption, checkedOptions = [],
optionIds = [],
containsVal = function(val) {
return isValDef &&
(isModeCheck?
Expand All @@ -20,7 +21,7 @@ block('select')(
iterateOptions(option.group);
} else {
firstOption || (firstOption = option);
option.id = _this.generateId();
optionIds.push(option.id = _this.generateId());
if(containsVal(option.val)) {
option.checked = true;
checkedOptions.push(option);
Expand All @@ -34,7 +35,8 @@ block('select')(
return applyNext({
_select : ctx,
_checkedOptions : checkedOptions,
_firstOption : firstOption
_firstOption : firstOption,
_optionsIds : optionIds
});
}),

Expand Down
6 changes: 4 additions & 2 deletions common.blocks/select/select.bh.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = function(bh) {
iterateOptions(option.group);
} else {
firstOption || (firstOption = option);
option.id = ctx.generateId();
optionIds.push(option.id = ctx.generateId());
if(containsVal(option.val)) {
option.checked = true;
checkedOptions.push(option);
Expand All @@ -28,7 +28,8 @@ module.exports = function(bh) {

var isValDef = typeof json.val !== 'undefined',
isModeCheck = ctx.mod('mode') === 'check',
firstOption, checkedOptions = [];
firstOption, checkedOptions = [],
optionIds = [];

iterateOptions(json.options);

Expand All @@ -40,6 +41,7 @@ module.exports = function(bh) {
.tParam('select', json)
.tParam('firstOption', firstOption)
.tParam('checkedOptions', checkedOptions)
.tParam('optionIds', optionIds)
.content([
{ elem : 'button' },
{
Expand Down

0 comments on commit 3fdb0fb

Please sign in to comment.