Skip to content

Commit b804387

Browse files
committed
Check if container exists before trying to delete it
1 parent 352ee92 commit b804387

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/scripts/basicModal.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,15 @@ const close = function(force) {
303303
container.classList.remove('basicModalContainer--fadeIn')
304304
container.classList.add('basicModalContainer--fadeOut')
305305

306-
setTimeout(() => container.parentElement.removeChild(container), 300)
306+
setTimeout(() => {
307+
308+
// Only close when container exists
309+
if (container==null) return false
310+
if (container.parentElement==null) return false
311+
312+
container.parentElement.removeChild(container)
313+
314+
}, 300)
307315

308316
// Restore last active element
309317
if (lastFocus!=null) {

0 commit comments

Comments
 (0)