Skip to content

Commit 33ff877

Browse files
MARCO AURELIO MESSAMARCO AURELIO MESSA
authored andcommitted
fix: call showModalDialog inside another function
Prevent showModalDialog from breaking when used inside another function. Reference: #41
1 parent ce0046b commit 33ff877

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

showModalDialog.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
dialog.addEventListener('close', function() {
145145
var returnValue = lastDialog.querySelector('#dialog-body').contentWindow.returnValue;
146146
dialogDocument.body.removeChild(dialog);
147-
nextStmts[0] = nextStmts[0].replace(new RegExp('(window\.)?' + callerName + '\(.*\)' , 'g'), JSON.stringify(returnValue));
147+
nextStmts[0] = nextStmts[0].replace(new RegExp('(window\.)?' + callerName + '.*(\\).*)$' , 'g'), JSON.stringify(returnValue) + "$2");
148148
var decodedStmts = nextStmts.join('\n').replace(/^function\s+\(\s*\)\s*{/, '');
149149
var unopenedBraces = (decodedStmts.match(/}/g) || []).length - (decodedStmts.match(/{/g) || []).length;
150150
var openBraces = repeat('{', unopenedBraces);

0 commit comments

Comments
 (0)