Skip to content

Commit

Permalink
MC-41898: Fix jQuery.trim() (#36)
Browse files Browse the repository at this point in the history
- Replace functions
  • Loading branch information
jcuerdo authored May 14, 2021
1 parent a7ab44f commit 659263a
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ Bundle.Selection.prototype = {
$grid.find('.checkbox').prop({checked: false});
var checkRowBySku = function (sku) {
sku = $.trim(sku);
sku = sku.trim();
$grid.find('.sku').filter(function () {
return $.trim($(this).text()) == sku;
return $(this).text().trim() == sku;
}).closest('tr').find('.checkbox').prop({checked: true});
};
$.each(bSelection.gridSelection.values().pop().toArray(), function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ define([

if ($(this).is(':checked')) {
selectedProductList[$(this).val()] = {
name: $.trim(tr.find('.col-name').html()),
sku: $.trim(tr.find('.col-sku').html()),
name: tr.find('.col-name').html().trim(),
sku: tr.find('.col-sku').html().trim(),
'product_id': $(this).val(),
'option_id': $('bundle_selection_id_' + optionIndex).val(),
'selection_price_value': 0,
Expand Down Expand Up @@ -186,7 +186,7 @@ define([
});
bSelection.gridRemoval.each(function (pair) {
$optionBox.find('.col-sku').filter(function () {
return $.trim($(this).text()) === pair.key; // find row by SKU
return $(this).text().trim() === pair.key; // find row by SKU
}).closest('tr').find('button.delete').trigger('click');
});
widget.refreshSortableElements();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ define([
.closest(this.options.summaryContainer)
.find(this.options.templates.summaryBlock)
.html();
template = mageTemplate($.trim(template), {
template = mageTemplate(template.trim(), {
data: {
_label_: this.cache.currentElement.options[key].title
}
Expand Down Expand Up @@ -107,7 +107,7 @@ define([
.closest(this.options.summaryContainer)
.find(this.options.templates.optionBlock)
.html();
template = mageTemplate($.trim(template), {
template = mageTemplate(template.trim(), {
data: {
_quantity_: this.cache.currentElement.options[this.cache.currentKey].selections[optionIndex].qty,
_label_: this.cache.currentElement.options[this.cache.currentKey].selections[optionIndex].name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ define([
errorOption,
allOptions = [];

newOption.label = $.trim(newOption.label);
newOption.label = newOption.label.trim();

if (_.isEmpty(newOption.label)) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ define([
product.id = element.val();
product.qty = 0;
element.closest('[data-role=row]').find('[data-column]').each(function (index, el) {
product[$(el).data('column')] = $.trim($(el).text());
product[$(el).data('column')] = $(el).text().trim();
});
selectedProductList[product.id] = product;
} else {
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Paypal/view/frontend/web/js/order-review.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ define([
isChecked = $(this.options.billingAsShippingSelector).is(':checked');
formData = null;
callBackResponseHandler = null;
shippingMethod = $.trim($(this.options.shippingSelector).val());
shippingMethod = $(this.options.shippingSelector).val().trim();
this._shippingTobilling();

if (url && resultId && shippingMethod) {
Expand Down Expand Up @@ -358,7 +358,7 @@ define([
* Actions on change Shipping Address data
*/
_onShippingChange: function () {
if (this.triggerPropertyChange && $.trim($(this.options.shippingSelector).val())) {
if (this.triggerPropertyChange && $(this.options.shippingSelector).val().trim()) {
this.element.find(this.options.shippingSelector).hide().end()
.find(this.options.shippingSelector + '_update').show();
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Ui/view/base/web/js/block-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ define([

templateLoader.loadTemplate(blockLoaderTemplatePath).done(function (blockLoaderTemplate) {
loaderImageHref.done(function (loaderHref) {
blockLoader = template($.trim(blockLoaderTemplate), {
blockLoader = template(blockLoaderTemplate.trim(), {
loaderImageHref: loaderHref
});
blockLoader = $(blockLoader);
Expand Down
6 changes: 3 additions & 3 deletions app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ define([
return false;
}

pass = $.trim(value);
pass = value.trim();

if (!pass.length) {
return true;
Expand All @@ -476,7 +476,7 @@ define([
return false;
}

pass = $.trim(value);
pass = value.trim();

if (pass.length === 0) {
return true;
Expand All @@ -500,7 +500,7 @@ define([
counter = 0,
passwordMinLength = $(elm).data('password-min-length'),
passwordMinCharacterSets = $(elm).data('password-min-character-sets'),
pass = $.trim(v),
pass = v.trim(),
result = pass.length >= passwordMinLength;

if (result === false) {
Expand Down
2 changes: 1 addition & 1 deletion lib/web/mage/backend/suggest.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ define([
* @private
*/
_value: function () {
return $.trim(this.element[this.element.is(':input') ? 'val' : 'text']());
return this.element[this.element.is(':input') ? 'val' : 'text']().trim();
},

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/web/mage/multiselect.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ define([
* @return {String}
*/
getSearchCriteria: function () {
return $.trim(this.$input.val());
return this.$input.val().trim();
},

/**
Expand Down
6 changes: 3 additions & 3 deletions lib/web/mage/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ define([
return false;
}
//strip leading and trailing spaces
pass = $.trim(v);
pass = v.trim();

if (!pass.length) {
return true;
Expand All @@ -668,7 +668,7 @@ define([
if (v == null) {
return false;
}
pass = $.trim(v);
pass = v.trim();
// strip leading and trailing spaces
if (pass.length === 0) {
return true;
Expand All @@ -692,7 +692,7 @@ define([
counter = 0,
passwordMinLength = $(elm).data('password-min-length'),
passwordMinCharacterSets = $(elm).data('password-min-character-sets'),
pass = $.trim(v),
pass = v.trim(),
result = pass.length >= passwordMinLength;

if (result === false) {
Expand Down

0 comments on commit 659263a

Please sign in to comment.