Skip to content

Commit

Permalink
Add separate public remove function instead of passing a boolean to scan
Browse files Browse the repository at this point in the history
  • Loading branch information
LiteracyFanatic committed Aug 14, 2023
1 parent ea66b6a commit f1be447
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1268,10 +1268,19 @@ export class ValidationService {
/**
* Scans the provided root element for any validation directives and attaches behavior to them.
*/
scan(root: ParentNode, remove: boolean = false) {
scan(root: ParentNode) {
this.logger.log('Scanning', root);
this.scanMessages(root, remove);
this.scanInputs(root, remove);
this.scanMessages(root);
this.scanInputs(root);
}

/**
* Scans the provided root element for any validation directives and removes behavior from them.
*/
remove(root: ParentNode) {
this.logger.log('Removing', root);
this.scanMessages(root, true);
this.scanInputs(root, true);
}

/**
Expand Down Expand Up @@ -1305,7 +1314,7 @@ export class ValidationService {
let node = mutation.removedNodes[i];
this.logger.log('Removed node', node);
if (node instanceof HTMLElement) {
this.scan(node, true);
this.remove(node);
}
}
} else if (mutation.type === 'attributes') {
Expand Down

0 comments on commit f1be447

Please sign in to comment.