Skip to content

Commit

Permalink
Replace removeAttr with removeAttribute. (#6228)
Browse files Browse the repository at this point in the history
This replaces jQuery's `removeAttr` function with the vanilla JavaScript
`removeAttribute`.

$results, $rendered, $selection and $search all seem to be defined as a
single element, so we can call `[0]` to get the element.
  • Loading branch information
p8 committed Mar 2, 2023
1 parent 8bdafc3 commit cd545a4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/js/select2/dropdown/search.js
Expand Up @@ -64,8 +64,8 @@ define([

container.on('close', function () {
self.$search.attr('tabindex', -1);
self.$search.removeAttr('aria-controls');
self.$search.removeAttr('aria-activedescendant');
self.$search[0].removeAttribute('aria-controls');
self.$search[0].removeAttribute('aria-activedescendant');

self.$search.val('');
self.$search.trigger('blur');
Expand Down Expand Up @@ -93,7 +93,7 @@ define([
if (params.data._resultId) {
self.$search.attr('aria-activedescendant', params.data._resultId);
} else {
self.$search.removeAttr('aria-activedescendant');
self.$search[0].removeAttribute('aria-activedescendant');
}
});
};
Expand Down
2 changes: 1 addition & 1 deletion src/js/select2/results.js
Expand Up @@ -318,7 +318,7 @@ define([
// When the dropdown is closed, aria-expended="false"
self.$results.attr('aria-expanded', 'false');
self.$results.attr('aria-hidden', 'true');
self.$results.removeAttr('aria-activedescendant');
self.$results[0].removeAttribute('aria-activedescendant');
});

container.on('results:toggle', function () {
Expand Down
4 changes: 2 additions & 2 deletions src/js/select2/selection/base.js
Expand Up @@ -78,8 +78,8 @@ define([
container.on('close', function () {
// 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[0].removeAttribute('aria-activedescendant');
self.$selection[0].removeAttribute('aria-owns');

self.$selection.trigger('focus');

Expand Down
6 changes: 3 additions & 3 deletions src/js/select2/selection/search.js
Expand Up @@ -51,8 +51,8 @@ define([
container.on('close', function () {
self.$search.val('');
self.resizeSearch();
self.$search.removeAttr('aria-controls');
self.$search.removeAttr('aria-activedescendant');
self.$search[0].removeAttribute('aria-controls');
self.$search[0].removeAttribute('aria-activedescendant');
self.$search.trigger('focus');
});

Expand All @@ -74,7 +74,7 @@ define([
if (params.data._resultId) {
self.$search.attr('aria-activedescendant', params.data._resultId);
} else {
self.$search.removeAttr('aria-activedescendant');
self.$search[0].removeAttribute('aria-activedescendant');
}
});

Expand Down
4 changes: 2 additions & 2 deletions src/js/select2/selection/single.js
Expand Up @@ -68,7 +68,7 @@ define([
SingleSelection.prototype.clear = function () {
var $rendered = this.$selection.find('.select2-selection__rendered');
$rendered.empty();
$rendered.removeAttr('title'); // clear tooltip on empty
$rendered[0].removeAttribute('title'); // clear tooltip on empty
};

SingleSelection.prototype.display = function (data, container) {
Expand Down Expand Up @@ -100,7 +100,7 @@ define([
if (title) {
$rendered.attr('title', title);
} else {
$rendered.removeAttr('title');
$rendered[0].removeAttribute('title');
}
};

Expand Down

0 comments on commit cd545a4

Please sign in to comment.