File tree Expand file tree Collapse file tree 3 files changed +367
-339
lines changed Expand file tree Collapse file tree 3 files changed +367
-339
lines changed Original file line number Diff line number Diff line change 4
4
* Copyright 2012-2013 Florian Friesdorf
5
5
* Copyright 2012-2013 Marko Durkovic
6
6
*/
7
+ import "../../core/polyfills" ; // SubmitEvent.submitter for Safari < 15.4 and jsDOM
7
8
import $ from "jquery" ;
8
9
import logging from "../../core/logging" ;
9
10
import Parser from "../../core/parser" ;
@@ -53,8 +54,8 @@ const _ = {
53
54
$el . off ( ".pat-ajax" ) ;
54
55
} ,
55
56
onClickSubmit ( event ) {
56
- const el = event . target ;
57
- const form = el . closest ( " form" ) ;
57
+ const el = event . submitter || event . target ;
58
+ const form = el . form ;
58
59
const data = { } ;
59
60
if ( el . name ) {
60
61
data [ el . name ] = el . value ;
Original file line number Diff line number Diff line change @@ -107,25 +107,18 @@ const inject = {
107
107
if ( $el [ 0 ] ?. tagName === "FORM" ) {
108
108
events . add_event_listener (
109
109
$el [ 0 ] ,
110
- "click " ,
111
- "pat-inject--form-submit-click " ,
110
+ "submit " ,
111
+ "pat-inject--form-submit" ,
112
112
( e ) => {
113
113
if (
114
- e . target . matches (
114
+ e . submitter ? .matches (
115
115
"[type=submit], button:not([type=button]), [type=image]"
116
116
)
117
117
) {
118
118
// make sure the submitting button is sent
119
119
// with the form
120
120
ajax . onClickSubmit ( e ) ;
121
121
}
122
- }
123
- ) ;
124
- events . add_event_listener (
125
- $el [ 0 ] ,
126
- "submit" ,
127
- "pat-inject--form-submit" ,
128
- ( e ) => {
129
122
this . onTrigger ( e ) ;
130
123
}
131
124
) ;
You can’t perform that action at this time.
0 commit comments