1
0
mirror of synced 2024-11-25 14:26:03 +03:00

Only use aria-owns when the dropdown is open

This fixes part of https://github.com/select2/select2/issues/3144.
This commit is contained in:
Kevin Brown 2015-03-14 19:39:28 -04:00
parent 7e4e8bc9d6
commit fc43f00b59
5 changed files with 10 additions and 8 deletions

View File

@ -1293,8 +1293,6 @@ S2.define('select2/selection/base',[
this.container = container;
this.$selection.attr('aria-owns', resultsId);
this.$selection.on('focus', function (evt) {
self.trigger('focus', evt);
});
@ -1322,6 +1320,7 @@ S2.define('select2/selection/base',[
container.on('open', function () {
// When the dropdown is open, aria-expanded="true"
self.$selection.attr('aria-expanded', 'true');
self.$selection.attr('aria-owns', resultsId);
self._attachCloseHandler(container);
});
@ -1330,6 +1329,7 @@ S2.define('select2/selection/base',[
// When the dropdown is closed, aria-expanded="false"
self.$selection.attr('aria-expanded', 'false');
self.$selection.removeAttr('aria-activedescendant');
self.$selection.removeAttr('aria-owns');
self.$selection.focus();
@ -4201,6 +4201,7 @@ S2.define('select2/i18n/en',[],function () {
S2.define('select2/defaults',[
'jquery',
'require',
'./results',
'./selection/single',

File diff suppressed because one or more lines are too long

5
dist/js/select2.js vendored
View File

@ -1293,8 +1293,6 @@ S2.define('select2/selection/base',[
this.container = container;
this.$selection.attr('aria-owns', resultsId);
this.$selection.on('focus', function (evt) {
self.trigger('focus', evt);
});
@ -1322,6 +1320,7 @@ S2.define('select2/selection/base',[
container.on('open', function () {
// When the dropdown is open, aria-expanded="true"
self.$selection.attr('aria-expanded', 'true');
self.$selection.attr('aria-owns', resultsId);
self._attachCloseHandler(container);
});
@ -1330,6 +1329,7 @@ S2.define('select2/selection/base',[
// When the dropdown is closed, aria-expanded="false"
self.$selection.attr('aria-expanded', 'false');
self.$selection.removeAttr('aria-activedescendant');
self.$selection.removeAttr('aria-owns');
self.$selection.focus();
@ -4201,6 +4201,7 @@ S2.define('select2/i18n/en',[],function () {
S2.define('select2/defaults',[
'jquery',
'require',
'./results',
'./selection/single',

File diff suppressed because one or more lines are too long

View File

@ -43,8 +43,6 @@ define([
this.container = container;
this.$selection.attr('aria-owns', resultsId);
this.$selection.on('focus', function (evt) {
self.trigger('focus', evt);
});
@ -72,6 +70,7 @@ define([
container.on('open', function () {
// When the dropdown is open, aria-expanded="true"
self.$selection.attr('aria-expanded', 'true');
self.$selection.attr('aria-owns', resultsId);
self._attachCloseHandler(container);
});
@ -80,6 +79,7 @@ define([
// When the dropdown is closed, aria-expanded="false"
self.$selection.attr('aria-expanded', 'false');
self.$selection.removeAttr('aria-activedescendant');
self.$selection.removeAttr('aria-owns');
self.$selection.focus();