@@ -187,7 +187,7 @@ describe("pat-autosubmit", function () {
187
187
expect ( submit_form_dispatched ) . toBe ( true ) ;
188
188
} ) ;
189
189
190
- it ( "2.6 - when pat-autosubmit is defined not on aform element" , async function ( ) {
190
+ it ( "2.6 - when pat-autosubmit is defined not on a form element" , async function ( ) {
191
191
document . body . innerHTML = `
192
192
<form>
193
193
<div
@@ -211,6 +211,40 @@ describe("pat-autosubmit", function () {
211
211
await utils . timeout ( 1 ) ;
212
212
expect ( submit_form_dispatched ) . toBe ( true ) ;
213
213
} ) ;
214
+
215
+ it ( "2.7 - directly on a pat-subform" , async function ( ) {
216
+ document . body . innerHTML = `
217
+ <form>
218
+ <div class="pat-subform">
219
+ <input
220
+ class="pat-autosubmit"
221
+ data-pat-autosubmit="delay: 0"
222
+ name="q">
223
+ </div>
224
+ </form>
225
+ ` ;
226
+ const input = document . querySelector ( "input" ) ;
227
+ const subform = document . querySelector ( ".pat-subform" ) ;
228
+ const autosubmit = document . querySelector ( ".pat-autosubmit" ) ;
229
+ new Pattern ( autosubmit ) ;
230
+
231
+ // The submit event should be invoked on the subform.
232
+ let submit_subform_dispatched = false ;
233
+ subform . addEventListener ( "submit" , ( ) => {
234
+ submit_subform_dispatched = true ;
235
+ } ) ;
236
+
237
+ // The submit event should also bubble up to the form.
238
+ let submit_form_dispatched = false ;
239
+ document . querySelector ( "form" ) . addEventListener ( "submit" , ( ) => {
240
+ submit_form_dispatched = true ;
241
+ } ) ;
242
+
243
+ input . dispatchEvent ( events . input_event ( ) ) ;
244
+ await utils . timeout ( 1 ) ;
245
+ expect ( submit_subform_dispatched ) . toBe ( true ) ;
246
+ expect ( submit_form_dispatched ) . toBe ( true ) ;
247
+ } ) ;
214
248
} ) ;
215
249
216
250
describe ( "3 - Parsing of the delay option" , function ( ) {
0 commit comments