8000 fix: removed deprecated JavaScript in cms.modal.js (#8192) · django-cms/django-cms@71d94be · GitHub
[go: up one dir, main page]

Skip to content

Commit 71d94be

Browse files
authored
fix: removed deprecated JavaScript in cms.modal.js (#8192)
* removes some deprecated JavaScript in cms.modal.js * fix gulp-lint anotation
1 parent f1cc413 commit 71d94be

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

cms/static/cms/js/modules/cms.modal.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -777,29 +777,28 @@ class Modal {
777777

778778
if (item.is('input') || item.is('button')) {
779779
that.ui.modalBody.addClass('cms-loader');
780-
var frm = item.closest('form');
780+
var frm = item[0].form;
781781

782782
// In Firefox with 1Password extension installed (FF 45 1password 4.5.6 at least)
783783
// the item[0].click() doesn't work, which notably breaks
784784
// deletion of the plugin. Workaround is that if the clicked button
785785
// is the only button in the form - submit a form, otherwise
786786
// 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) {
788788
// we need to use native `.click()` event specifically
789789
// as we are inside an iframe and magic is happening
790790
item[0].click();
791791
} else {
792792
// have to dispatch native submit event so all the submit handlers
793793
// can be fired, see #5590
794-
var evt = document.createEvent('HTMLEvents');
794+
var evt = new CustomEvent('submit', { bubbles: false, cancelable: true });
795795

796-
evt.initEvent('submit', false, true);
797-
if (frm[0].dispatchEvent(evt)) {
796+
if (frm.dispatchEvent(evt)) {
798797
// triggering submit event in webkit based browsers won't
799798
// actually submit the form, while in Gecko-based ones it
800799
// will and calling frm.submit() would throw NS_ERROR_UNEXPECTED
801800
try {
802-
frm[0].submit();
801+
frm.submit();
803802
} catch (err) {}
804803
}
805804
}

0 commit comments

Comments
 (0)
0