Skip to content

Commit

Permalink
ensure title retains previous functionality (#2147)
Browse files Browse the repository at this point in the history
  • Loading branch information
caseyjhol committed Apr 23, 2020
1 parent 2062284 commit 1648146
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions js/bootstrap-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,19 @@
}
}
}

function getAttributesObject($select) {
var attributesObject = {},
attrVal;

ParseableAttributes.forEach(function (item, index) {
if(attrVal = $select.attr(item)) attributesObject[item] = attrVal;
});
if(!attributesObject.placeholder && attributesObject.title) attributesObject.placeholder = attributesObject.title; // for backwards compat.

// for backwards compatibility
// (using title as placeholder is deprecated - remove in v2.0.0)
if (attributesObject.title) attributesObject.placeholder = attributesObject.title;

return attributesObject;
}

Expand Down Expand Up @@ -1865,7 +1871,7 @@

// if the select has a title, apply it to the button, and if not, apply titleFragment text
// strip all HTML tags and trim the result, then unescape any escaped tags
button.title = (this.options.title ? this.options.title : titleFragment.textContent).replace(/<[^>]*>?/g, '').trim();
button.title = titleFragment.textContent.replace(/<[^>]*>?/g, '').trim();

if (this.options.sanitize && hasContent) {
sanitizeHtml([titleFragment], that.options.whiteList, that.options.sanitizeFn);
Expand Down Expand Up @@ -3229,6 +3235,10 @@
var data = $this.data('selectpicker'),
options = typeof _option == 'object' && _option;

// for backwards compatibility
// (using title as placeholder is deprecated - remove in v2.0.0)
if (options.title) options.placeholder = options.title;

if (!data) {
var dataAttributes = $this.data();

Expand Down

0 comments on commit 1648146

Please sign in to comment.