dimsemenov/Magnific-Popup — pull request #430 by peterkuma (2014-04-06 20:55:03+00:00)
Title: Fix close event handling (#362)

The way mfp._checkIfClose checks if target is in content is not
reliable, because the event may have been handled before it bubbled to
mfp.wrap, causing such changes to DOM that the target is no longer in
content.

This fix adds a click event handler to mfp.contentContainer which sets
an indicator that the event came from content. This indicator is passed
to mfp._checkIfClose, which uses it instead of the original $.contains
check. The indicator cannot be set on the event object itself, as it is
not preserved by jQuery while bubbling. It is set on the target instead
and removed in the mfp.wrap click event handler.

The fix is somewhat dirty, so it may not be considered suitable for
merging, but it works with the example outlined in the issue report
(#362), and with the examples on the demo page.