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

Chore/remove jquery stage ii #962

Merged
merged 2 commits into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions dist/client-side-validations.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -661,17 +661,20 @@ var executeValidators = function executeValidators(validatorFunctions, $element,
return true;
};
var isMarkedForDestroy = function isMarkedForDestroy($element) {
var elementName = $element.attr('name');
var element = $element[0];
var elementName = element.name;
if (/\[([^\]]*?)\]$/.test(elementName)) {
var destroyInputName = elementName.replace(/\[([^\]]*?)\]$/, '[_destroy]');
if (jQuery("input[name=\"".concat(destroyInputName, "\"]")).val() === '1') {
var destroyInputElement = document.querySelector("input[name=\"".concat(destroyInputName, "\"]"));
if (destroyInputElement && destroyInputElement.value === '1') {
return true;
}
}
return false;
};
var executeAllValidators = function executeAllValidators($element, validators) {
if ($element.data('changed') === false || $element.prop('disabled')) {
var element = $element[0];
if ($element.data('changed') === false || element.disabled) {
return;
}
$element.data('changed', false);
Expand Down
9 changes: 6 additions & 3 deletions dist/client-side-validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -665,17 +665,20 @@
return true;
};
var isMarkedForDestroy = function isMarkedForDestroy($element) {
var elementName = $element.attr('name');
var element = $element[0];
var elementName = element.name;
if (/\[([^\]]*?)\]$/.test(elementName)) {
var destroyInputName = elementName.replace(/\[([^\]]*?)\]$/, '[_destroy]');
if (jQuery("input[name=\"".concat(destroyInputName, "\"]")).val() === '1') {
var destroyInputElement = document.querySelector("input[name=\"".concat(destroyInputName, "\"]"));
if (destroyInputElement && destroyInputElement.value === '1') {
return true;
}
}
return false;
};
var executeAllValidators = function executeAllValidators($element, validators) {
if ($element.data('changed') === false || $element.prop('disabled')) {
var element = $element[0];
if ($element.data('changed') === false || element.disabled) {
return;
}
$element.data('changed', false);
Expand Down
9 changes: 6 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,14 @@ const executeValidators = (validatorFunctions, $element, validators) => {
}

const isMarkedForDestroy = ($element) => {
const elementName = $element.attr('name')
const element = $element[0]
const elementName = element.name

if (/\[([^\]]*?)\]$/.test(elementName)) {
const destroyInputName = elementName.replace(/\[([^\]]*?)\]$/, '[_destroy]')
const destroyInputElement = document.querySelector(`input[name="${destroyInputName}"]`)

if (jQuery(`input[name="${destroyInputName}"]`).val() === '1') {
if (destroyInputElement && destroyInputElement.value === '1') {
return true
}
}
Expand All @@ -182,7 +184,8 @@ const isMarkedForDestroy = ($element) => {
}

const executeAllValidators = ($element, validators) => {
if ($element.data('changed') === false || $element.prop('disabled')) {
const element = $element[0]
if ($element.data('changed') === false || element.disabled) {
return
}

Expand Down
9 changes: 6 additions & 3 deletions vendor/assets/javascripts/rails.validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -665,17 +665,20 @@
return true;
};
var isMarkedForDestroy = function isMarkedForDestroy($element) {
var elementName = $element.attr('name');
var element = $element[0];
var elementName = element.name;
if (/\[([^\]]*?)\]$/.test(elementName)) {
var destroyInputName = elementName.replace(/\[([^\]]*?)\]$/, '[_destroy]');
if (jQuery("input[name=\"".concat(destroyInputName, "\"]")).val() === '1') {
var destroyInputElement = document.querySelector("input[name=\"".concat(destroyInputName, "\"]"));
if (destroyInputElement && destroyInputElement.value === '1') {
return true;
}
}
return false;
};
var executeAllValidators = function executeAllValidators($element, validators) {
if ($element.data('changed') === false || $element.prop('disabled')) {
var element = $element[0];
if ($element.data('changed') === false || element.disabled) {
return;
}
$element.data('changed', false);
Expand Down
Loading