@@ -777,29 +777,28 @@ class Modal {
777
777
778
778
if ( item . is ( 'input' ) || item . is ( 'button' ) ) {
779
779
that . ui . modalBody . addClass ( 'cms-loader' ) ;
780
- var frm = item . closest ( ' form' ) ;
780
+ var frm = item [ 0 ] . form ;
781
781
782
782
// In Firefox with 1Password extension installed (FF 45 1password 4.5.6 at least)
783
783
// the item[0].click() doesn't work, which notably breaks
784
784
// deletion of the plugin. Workaround is that if the clicked button
785
785
// is the only button in the form - submit a form, otherwise
786
786
// click on the button
787
- if ( frm . find ( 'button, input[type="button"], input[type="submit"]' ) . length > 1 ) {
787
+ if ( frm . querySelectorAll ( 'button, input[type="button"], input[type="submit"]' ) . length > 1 ) {
788
788
// we need to use native `.click()` event specifically
789
789
// as we are inside an iframe and magic is happening
790
790
item [ 0 ] . click ( ) ;
791
791
} else {
792
792
// have to dispatch native submit event so all the submit handlers
793
793
// can be fired, see #5590
794
- var evt = document . createEvent ( 'HTMLEvents' ) ;
794
+ var evt = new CustomEvent ( 'submit' , { bubbles : false , cancelable : true } ) ;
795
795
796
- evt . initEvent ( 'submit' , false , true ) ;
797
- if ( frm [ 0 ] . dispatchEvent ( evt ) ) {
796
+ if ( frm . dispatchEvent ( evt ) ) {
798
797
// triggering submit event in webkit based browsers won't
799
798
// actually submit the form, while in Gecko-based ones it
800
799
// will and calling frm.submit() would throw NS_ERROR_UNEXPECTED
801
800
try {
802
- frm [ 0 ] . submit ( ) ;
801
+ frm . submit ( ) ;
803
802
} catch ( err ) { }
804
803
}
805
804
}
0 commit comments