1
Fork 0

make .validate() prepare fields that do not currently exist

This commit is contained in:
Conduitry 2022-07-22 17:19:49 -04:00
parent 00460240fa
commit 93ae65f384
1 changed files with 4 additions and 7 deletions

View File

@ -15,7 +15,7 @@ export const field = (validator) => {
set(validity);
};
const enable_message = () => {
const validate = () => {
message_enabled = true;
update();
};
@ -24,8 +24,7 @@ export const field = (validator) => {
node = new_node;
value = new_value;
update();
node.addEventListener('blur', enable_message, true);
node.addEventListener('blur', validate, true);
return {
update(new_value) {
@ -33,16 +32,14 @@ export const field = (validator) => {
update();
},
destroy() {
node.removeEventListener('blur', enable_message);
node.removeEventListener('blur', validate);
node = null;
message_enabled = false;
update();
},
};
};
action.validate = () => node && enable_message();
action.validate = validate;
action.subscribe = subscribe;