1
0
mirror of synced 2024-11-22 21:16:10 +03:00

Merge pull request #1795 from arendjr/master

Don't rely on :selected, makes Select2 compatible with jQuery builds without Sizzle
This commit is contained in:
Igor Vaynberg 2013-10-15 08:04:21 -07:00
commit e84a1207d0

View File

@ -2119,7 +2119,7 @@ the specific language governing permissions and limitations under the Apache Lic
isPlaceholderOptionSelected: function() {
var placeholderOption;
if (!this.getPlaceholder()) return false; // no placeholder specified so no option should be considered
return ((placeholderOption = this.getPlaceholderOption()) !== undefined && placeholderOption.is(':selected'))
return ((placeholderOption = this.getPlaceholderOption()) !== undefined && placeholderOption.prop("selected"))
|| (this.opts.element.val() === "")
|| (this.opts.element.val() === undefined)
|| (this.opts.element.val() === null);
@ -2133,7 +2133,7 @@ the specific language governing permissions and limitations under the Apache Lic
if (opts.element.get(0).tagName.toLowerCase() === "select") {
// install the selection initializer
opts.initSelection = function (element, callback) {
var selected = element.find(":selected");
var selected = element.find("option").filter(function() { return this.selected });
// a single select box always has a value, no need to null check 'selected'
callback(self.optionToData(selected));
};
@ -2303,7 +2303,7 @@ the specific language governing permissions and limitations under the Apache Lic
if (this.select) {
this.select
.val(val)
.find(":selected").each2(function (i, elm) {
.find("option").filter(function() { return this.selected }).each2(function (i, elm) {
data = self.optionToData(elm);
return false;
});
@ -2398,7 +2398,7 @@ the specific language governing permissions and limitations under the Apache Lic
var data = [];
element.find(":selected").each2(function (i, elm) {
element.find("option").filter(function() { return this.selected }).each2(function (i, elm) {
data.push(self.optionToData(elm));
});
callback(data);