From 16481464dbf3b6f5c29173f7d0a2876f7cda07c2 Mon Sep 17 00:00:00 2001 From: Casey Holzer Date: Wed, 22 Apr 2020 18:15:44 -0600 Subject: [PATCH] ensure title retains previous functionality (#2147) --- js/bootstrap-select.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/js/bootstrap-select.js b/js/bootstrap-select.js index 0b8a45fdd..9ebd0943f 100644 --- a/js/bootstrap-select.js +++ b/js/bootstrap-select.js @@ -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; } @@ -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); @@ -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();