Skip to content

Commit

Permalink
Use attr instead of prop for select2-selection__rendered title (#…
Browse files Browse the repository at this point in the history
…4640)

See #3895, and jQuery docs on `attr`:

> As of jQuery 1.6, the .prop() method provides a way to explicitly retrieve property values, while .attr() retrieves attributes.
  • Loading branch information
timothykang authored and alexweissman committed Oct 26, 2017
1 parent a395ad1 commit 6ff1068
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -8,7 +8,7 @@

### Bug fixes
- Add `;` before beginning of factory wrapper (#5089)
- Clear tooltip from `select2-selection__rendered` when selection is cleared (#4746)
- Clear tooltip from `select2-selection__rendered` when selection is cleared (#4640, #4746)
- Fix keyboard not closing when closing dropdown on iOS 10 (#4680)
- User-defined types not normalized properly when passed in as data (#4632)
- Fix "the results could not be loaded" displaying during AJAX request (#4356)
Expand Down
4 changes: 2 additions & 2 deletions src/js/select2/selection/multiple.js
Expand Up @@ -55,7 +55,7 @@ define([
};

MultipleSelection.prototype.clear = function () {
this.$selection.find('.select2-selection__rendered').empty();
this.$selection.find('.select2-selection__rendered').empty().removeAttr('title');
};

MultipleSelection.prototype.display = function (data, container) {
Expand Down Expand Up @@ -93,7 +93,7 @@ define([
var formatted = this.display(selection, $selection);

$selection.append(formatted);
$selection.prop('title', selection.title || selection.text);
$selection.attr('title', selection.title || selection.text);

$selection.data('data', selection);

Expand Down
5 changes: 2 additions & 3 deletions src/js/select2/selection/single.js
Expand Up @@ -66,10 +66,9 @@ define([
};

SingleSelection.prototype.clear = function () {

var $rendered = this.$selection.find('.select2-selection__rendered');
$rendered.empty();
$rendered.attr('title',''); // clear tooltip on empty
$rendered.removeAttr('title'); // clear tooltip on empty
};

SingleSelection.prototype.display = function (data, container) {
Expand All @@ -95,7 +94,7 @@ define([
var formatted = this.display(selection, $rendered);

$rendered.empty().append(formatted);
$rendered.prop('title', selection.title || selection.text);
$rendered.attr('title', selection.title || selection.text);
};

return SingleSelection;
Expand Down

0 comments on commit 6ff1068

Please sign in to comment.