Skip to content

Commit

Permalink
Use dataset to access CSV Settings (#963)
Browse files Browse the repository at this point in the history
According to jQuery's data implementation, this should be a
backward-compatible change

Ref: 
- https://github.com/jquery/jquery/blob/f79d5f1a337528940ab7029d4f8bbba72326f269/src/data.js#L42-L44
- https://api.jquery.com/data/#data-html5
  • Loading branch information
tagliala authored Dec 15, 2024
1 parent 5dcb4ac commit 506dd4d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/client-side-validations.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ var ClientSideValidations = {
form: function form(_form2) {
var $form = jQuery(_form2);
_form2.ClientSideValidations = {
settings: $form.data('clientSideValidations'),
settings: JSON.parse(_form2.dataset.clientSideValidations),
addError: function addError($element, message) {
return ClientSideValidations.formBuilders[_form2.ClientSideValidations.settings.html_settings.type].add($element, _form2.ClientSideValidations.settings.html_settings, message);
},
Expand Down
2 changes: 1 addition & 1 deletion dist/client-side-validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
form: function form(_form2) {
var $form = jQuery(_form2);
_form2.ClientSideValidations = {
settings: $form.data('clientSideValidations'),
settings: JSON.parse(_form2.dataset.clientSideValidations),
addError: function addError($element, message) {
return ClientSideValidations.formBuilders[_form2.ClientSideValidations.settings.html_settings.type].add($element, _form2.ClientSideValidations.settings.html_settings, message);
},
Expand Down
2 changes: 1 addition & 1 deletion src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const ClientSideValidations = {
const $form = jQuery(form)

form.ClientSideValidations = {
settings: $form.data('clientSideValidations'),
settings: JSON.parse(form.dataset.clientSideValidations),
addError: ($element, message) => ClientSideValidations
.formBuilders[form.ClientSideValidations.settings.html_settings.type]
.add($element, form.ClientSideValidations.settings.html_settings, message),
Expand Down
2 changes: 1 addition & 1 deletion vendor/assets/javascripts/rails.validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
form: function form(_form2) {
var $form = jQuery(_form2);
_form2.ClientSideValidations = {
settings: $form.data('clientSideValidations'),
settings: JSON.parse(_form2.dataset.clientSideValidations),
addError: function addError($element, message) {
return ClientSideValidations.formBuilders[_form2.ClientSideValidations.settings.html_settings.type].add($element, _form2.ClientSideValidations.settings.html_settings, message);
},
Expand Down

0 comments on commit 506dd4d

Please sign in to comment.