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

Always use data-pristine-attribute if the 2 variants of the attribute exists #98

Open
wants to merge 1 commit into
base: master
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions dist/pristine.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,10 @@
var fns = [];
var params = {};
var messages = {};
var dataPristineAttr = [];

[].forEach.call(input.attributes, function (attr) {
if (dataPristineAttr.includes(attr.name)) return;
if (/^data-pristine-/.test(attr.name)) {
var name = attr.name.substr(14);
var messageMatch = name.match(MESSAGE_REGEX);
Expand All @@ -136,6 +138,7 @@
return;
}
if (name === 'type') name = attr.value;
dataPristineAttr.push(name);
_addValidatorToField(fns, params, name, attr.value);
} else if (~ALLOWED_ATTRIBUTES.indexOf(attr.name)) {
_addValidatorToField(fns, params, attr.name, attr.value);
Expand Down
2 changes: 1 addition & 1 deletion dist/pristine.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/pristine.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ export default function Pristine(form, config, live){
let fns = [];
let params = {};
let messages = {};
let dataPristineAttr = [];

[].forEach.call(input.attributes, function (attr) {
if (dataPristineAttr.includes(attr.name)) return;
if (/^data-pristine-/.test(attr.name)) {
let name = attr.name.substr(14);
let messageMatch = name.match(MESSAGE_REGEX);
Expand All @@ -69,6 +71,7 @@ export default function Pristine(form, config, live){
return;
}
if (name === 'type') name = attr.value;
dataPristineAttr.push(name);
_addValidatorToField(fns, params, name, attr.value);
} else if (~ALLOWED_ATTRIBUTES.indexOf(attr.name)){
_addValidatorToField(fns, params, attr.name, attr.value);
Expand Down