Skip to content

Commit e218af2

Browse files
committed
fix(pat-validation): Make sure to cancel submit events on invalid forms.
Make sure that submit events are canceled on invalid forms by using a capturing event handler which is invoked before non-capturing events. The previous commit exposed a problem with the submit event handling, where the then non-capturing submit event handler was registered later than the one from pat-inject because pat-validation's async init method where pat-inject's init method is yet non-async. That happened even the pat-validation's pattern initialization is enforced to run first due to registration reordering in the Pattern registry. Now with the capturing event handler this problem is fixed.
1 parent 11543ea commit e218af2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/pat/validation/validation.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ class Pattern extends BasePattern {
5353
logger.debug("Checking input for submit", input, e);
5454
this.check_input({ input: input, event: e });
5555
}
56-
}
56+
},
57+
// Make sure this event handler is run early, in the capturing
58+
// phase in order to be able to cancel later non-capturing submit
59+
// events.
60+
{ capture: true }
5761
);
5862

5963
this.initialize_inputs();

0 commit comments

Comments
 (0)