diff --git a/dist/client-side-validations.esm.js b/dist/client-side-validations.esm.js index 101a015d..3088dfd0 100644 --- a/dist/client-side-validations.esm.js +++ b/dist/client-side-validations.esm.js @@ -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); diff --git a/dist/client-side-validations.js b/dist/client-side-validations.js index d8ac4f04..2ce97c4b 100644 --- a/dist/client-side-validations.js +++ b/dist/client-side-validations.js @@ -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); diff --git a/src/index.js b/src/index.js index 7d306855..fe99561d 100644 --- a/src/index.js +++ b/src/index.js @@ -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 } } @@ -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 } diff --git a/vendor/assets/javascripts/rails.validations.js b/vendor/assets/javascripts/rails.validations.js index d8ac4f04..2ce97c4b 100644 --- a/vendor/assets/javascripts/rails.validations.js +++ b/vendor/assets/javascripts/rails.validations.js @@ -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);