File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -97,7 +97,11 @@ const inject = {
9797 // setup event handlers
9898 if ( $el . is ( "form" ) ) {
9999 $el . on ( "submit.pat-inject" , this . onTrigger . bind ( this ) )
100- . on ( "click.pat-inject" , "[type=submit]" , ajax . onClickSubmit )
100+ . on (
101+ "click.pat-inject" ,
102+ "[type=submit]:not([formaction])" ,
103+ ajax . onClickSubmit
104+ )
101105 . on (
102106 "click.pat-inject" ,
103107 "[type=submit][formaction], [type=image][formaction]" ,
Original file line number Diff line number Diff line change @@ -1221,6 +1221,25 @@ describe("pat-inject", function () {
12211221 "other"
12221222 ) ;
12231223 } ) ;
1224+
1225+ it ( "9.2.5.10 - does not call ajax.onClickSubmit twice." , async function ( ) {
1226+ document . body . innerHTML = `
1227+ <form class="pat-inject">
1228+ <button type="submit" formaction="test.cgi"/>
1229+ </form>
1230+ ` ;
1231+
1232+ const pat_ajax = ( await import ( "../ajax/ajax.js" ) ) . default ;
1233+ jest . spyOn ( pat_ajax , "onClickSubmit" ) ;
1234+
1235+ const form = document . querySelector ( "form" ) ;
1236+ const button = form . querySelector ( "button" ) ;
1237+
1238+ pattern . init ( $ ( form ) ) ;
1239+ button . click ( ) ;
1240+
1241+ expect ( pat_ajax . onClickSubmit ) . toHaveBeenCalledTimes ( 1 ) ;
1242+ } ) ;
12241243 } ) ;
12251244 } ) ;
12261245 } ) ;
You can’t perform that action at this time.
0 commit comments