});
this.dispatchEvent(evt);
+ // Canceling this event is interpreted as a form validation failure.
if (evt.defaultPrevented) {
event.preventDefault();
+ return;
}
if (evt.detail.length > 0) {
}
});
}
-
- if (!this.#shouldClose()) {
+ // There were no validation handlers to process, so validation has passed.
+ // By default the browser will close the dialog unless the submit event’s default action gets prevented.
+ else if (!this.#shouldClose()) {
// Prevent the browser from closing the dialog
event.preventDefault();
// but dispatch the `primary` event
if (this.#shouldClose()) {
this.#detachDialog();
- }
- else {
+ } else {
// Prevent the browser from closing the dialog.
event.preventDefault();
}
detail: callbacks,
});
this.dispatchEvent(evt);
+ // Canceling this event is interpreted as a form validation failure.
if (evt.defaultPrevented) {
event.preventDefault();
+ return;
}
if (evt.detail.length > 0) {
// DOM events cannot wait for async functions. We must
}
});
}
- if (!this.#shouldClose()) {
+ // There were no validation handlers to process, so validation has passed.
+ // By default the browser will close the dialog unless the submit event’s default action gets prevented.
+ else if (!this.#shouldClose()) {
// Prevent the browser from closing the dialog
event.preventDefault();
// but dispatch the `primary` event