Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove prop() function #6289

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/js/select2/core.js
Expand Up @@ -335,7 +335,7 @@ define([
};

Select2.prototype._syncAttributes = function () {
this.options.set('disabled', this.$element.prop('disabled'));
this.options.set('disabled', this.$element[0].disabled);

if (this.isDisabled()) {
if (this.isOpen()) {
Expand Down Expand Up @@ -497,7 +497,7 @@ define([
if (this.options.get('debug') && window.console && console.warn) {
console.warn(
'Select2: The `select2("enable")` method has been deprecated and will' +
' be removed in later Select2 versions. Use $element.prop("disabled")' +
' be removed in later Select2 versions. Use $element[0].disabled' +
' instead.'
);
}
Expand All @@ -508,7 +508,7 @@ define([

var disabled = !args[0];

this.$element.prop('disabled', disabled);
this.$element[0].disabled = disabled;
};

Select2.prototype.data = function () {
Expand Down
14 changes: 7 additions & 7 deletions src/js/select2/data/select.js
Expand Up @@ -41,7 +41,7 @@ define([
return;
}

if (this.$element.prop('multiple')) {
if (this.$element[0].multiple) {
this.current(function (currentData) {
var val = [];

Expand Down Expand Up @@ -70,7 +70,7 @@ define([
SelectAdapter.prototype.unselect = function (data) {
var self = this;

if (!this.$element.prop('multiple')) {
if (!this.$element[0].multiple) {
return;
}

Expand Down Expand Up @@ -216,15 +216,15 @@ define([
data = {
id: $option.val(),
text: $option.text(),
disabled: $option.prop('disabled'),
selected: $option.prop('selected'),
title: $option.prop('title')
disabled: $option[0].disabled,
selected: $option[0].selected,
title: $option[0].title
};
} else if (option.tagName.toLowerCase() === 'optgroup') {
data = {
text: $option.prop('label'),
text: $option[0].label,
children: [],
title: $option.prop('title')
title: $option[0].title
};

var $children = $option.children('option');
Expand Down
5 changes: 3 additions & 2 deletions src/js/select2/defaults.js
Expand Up @@ -326,8 +326,9 @@ define([
Defaults.prototype.applyFromElement = function (options, $element) {
var optionLanguage = options.language;
var defaultLanguage = this.defaults.language;
var elementLanguage = $element.prop('lang');
var parentLanguage = $element.closest('[lang]').prop('lang');
var elementLanguage = $element[0].lang;
var elementClosest = $element.closest('[lang]');
var parentLanguage = elementClosest[0] ? elementClosest[0].lang : null;

var languages = Array.prototype.concat.call(
this._resolveLanguage(elementLanguage),
Expand Down
2 changes: 1 addition & 1 deletion src/js/select2/dropdown/search.js
Expand Up @@ -18,7 +18,7 @@ define([
this.$searchContainer = $search;
this.$search = $search.find('input');

this.$search.prop('autocomplete', this.options.get('autocomplete'));
this.$search[0].autocomplete = this.options.get('autocomplete');
this.$search.attr('aria-label', searchLabel());

$rendered.prepend($search);
Expand Down
30 changes: 18 additions & 12 deletions src/js/select2/options.js
Expand Up @@ -21,29 +21,35 @@ define([
var excludedData = ['select2'];

if (this.options.multiple == null) {
this.options.multiple = $e.prop('multiple');
this.options.multiple = $e[0].multiple;
}

if (this.options.disabled == null) {
this.options.disabled = $e.prop('disabled');
this.options.disabled = $e[0].disabled;
}

if (this.options.autocomplete == null && $e.prop('autocomplete')) {
this.options.autocomplete = $e.prop('autocomplete');
if (this.options.autocomplete == null && $e[0].autocomplete) {
this.options.autocomplete = $e[0].autocomplete;
}

if (this.options.dir == null) {
if ($e.prop('dir')) {
this.options.dir = $e.prop('dir');
} else if ($e.closest('[dir]').prop('dir')) {
this.options.dir = $e.closest('[dir]').prop('dir');
if (this.options.dir === null) {
var dirValue = $e[0].getAttribute('dir');

if (dirValue) {
this.options.dir = dirValue;
} else {
this.options.dir = 'ltr';
var closestDirValue = $e.closest('[dir]').getAttribute('dir');

if (closestDirValue) {
this.options.dir = closestDirValue;
} else {
this.options.dir = 'ltr';
}
}
}

$e.prop('disabled', this.options.disabled);
$e.prop('multiple', this.options.multiple);
$e[0].disabled = this.options.disabled;
$e[0].multiple = this.options.multiple;

if (Utils.GetData($e[0], 'select2Tags')) {
if (this.options.debug && window.console && console.warn) {
Expand Down
6 changes: 3 additions & 3 deletions src/js/select2/selection/search.js
Expand Up @@ -22,7 +22,7 @@ define([
this.$searchContainer = $search;
this.$search = $search.find('textarea');

this.$search.prop('autocomplete', this.options.get('autocomplete'));
this.$search.autocomplete = this.options.get('autocomplete');
this.$search.attr('aria-label', searchLabel());

var $rendered = decorated.call(this);
Expand Down Expand Up @@ -57,13 +57,13 @@ define([
});

container.on('enable', function () {
self.$search.prop('disabled', false);
self.$search[0].disabled = false;

self._transferTabIndex();
});

container.on('disable', function () {
self.$search.prop('disabled', true);
self.$search[0].disabled = true;
});

container.on('focus', function (evt) {
Expand Down