Skip to content

Commit e84a120

Browse files
committed
Merge pull request select2#1795 from arendjr/master
Don't rely on :selected, makes Select2 compatible with jQuery builds without Sizzle
2 parents f1807f2 + fc44b96 commit e84a120

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

select2.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2119,7 +2119,7 @@ the specific language governing permissions and limitations under the Apache Lic
21192119
isPlaceholderOptionSelected: function() {
21202120
var placeholderOption;
21212121
if (!this.getPlaceholder()) return false; // no placeholder specified so no option should be considered
2122-
return ((placeholderOption = this.getPlaceholderOption()) !== undefined && placeholderOption.is(':selected'))
2122+
return ((placeholderOption = this.getPlaceholderOption()) !== undefined && placeholderOption.prop("selected"))
21232123
|| (this.opts.element.val() === "")
21242124
|| (this.opts.element.val() === undefined)
21252125
|| (this.opts.element.val() === null);
@@ -2133,7 +2133,7 @@ the specific language governing permissions and limitations under the Apache Lic
21332133
if (opts.element.get(0).tagName.toLowerCase() === "select") {
21342134
// install the selection initializer
21352135
opts.initSelection = function (element, callback) {
2136-
var selected = element.find(":selected");
2136+
var selected = element.find("option").filter(function() { return this.selected });
21372137
// a single select box always has a value, no need to null check 'selected'
21382138
callback(self.optionToData(selected));
21392139
};
@@ -2303,7 +2303,7 @@ the specific language governing permissions and limitations under the Apache Lic
23032303
if (this.select) {
23042304
this.select
23052305
.val(val)
2306-
.find(":selected").each2(function (i, elm) {
2306+
.find("option").filter(function() { return this.selected }).each2(function (i, elm) {
23072307
data = self.optionToData(elm);
23082308
return false;
23092309
});
@@ -2398,7 +2398,7 @@ the specific language governing permissions and limitations under the Apache Lic
23982398

23992399
var data = [];
24002400

2401-
element.find(":selected").each2(function (i, elm) {
2401+
element.find("option").filter(function() { return this.selected }).each2(function (i, elm) {
24022402
data.push(self.optionToData(elm));
24032403
});
24042404
callback(data);

0 commit comments

Comments
 (0)