Lightbox: Fixed incorrect closing of AJAX popups.

Fixes #5594. Fixes #5391.

Issue caused by doctype, html element and comments in the AJAXed content. Seems to trip up Magnific Popup by making mfp.content[0] into a text object (which breaks the $.contains checks). This seems to be a bug with Magnific Popup but removing doctype, html and comments from the AJAXed in content is successful as a workaround.