Access element that previously had focus when closing jQuery dialog

Access element that previously had focus when closing jQuery dialog

In #8730 the functionality was added to reset focus to where it was in the DOM before the dialog was opened when the dialog closes. Is it possible for me to access that element using a variable or something to check whether that element still exists?

The scenario I'm dealing with is that we open a dialog from a menu, so when the dialog closes, the menu has already closed and the button used to open the dialog (that had focus) no longer exists in the DOM. I'd like to check if it exists, and if not, do my own focus handling when the dialog closes.

Is it possible to access that saved information from the dialog? If not, could it be added?