Detect classes separated by multiple spaces
This detects classes separated by multiple spaces and will trim extra spaces surrounding the class attribute. This closes the following issue: https://github.com/ivaynberg/select2/issues/2358
This commit is contained in:
parent
9e17f63013
commit
3fee8fc7e6
15
select2.js
15
select2.js
@ -320,27 +320,34 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
function syncCssClasses(dest, src, adapter) {
|
||||
var classes, replacements = [], adapted;
|
||||
|
||||
classes = dest.attr("class");
|
||||
classes = $.trim(dest.attr("class"));
|
||||
|
||||
if (classes) {
|
||||
classes = '' + classes; // for IE which returns object
|
||||
$(classes.split(" ")).each2(function() {
|
||||
|
||||
$(classes.split(/\s+/)).each2(function() {
|
||||
if (this.indexOf("select2-") === 0) {
|
||||
replacements.push(this);
|
||||
}
|
||||
});
|
||||
}
|
||||
classes = src.attr("class");
|
||||
|
||||
classes = $.trim(src.attr("class"));
|
||||
|
||||
if (classes) {
|
||||
classes = '' + classes; // for IE which returns object
|
||||
$(classes.split(" ")).each2(function() {
|
||||
|
||||
$(classes.split(/\s+/)).each2(function() {
|
||||
if (this.indexOf("select2-") !== 0) {
|
||||
adapted = adapter(this);
|
||||
|
||||
if (adapted) {
|
||||
replacements.push(adapted);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dest.attr("class", replacements.join(" "));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user