Created
October 3, 2013 20:02
-
-
Save dkordik/6816224 to your computer and use it in GitHub Desktop.
Image error events don't bubble, (see http://www.w3.org/TR/DOM-Level-3-Events/#event-type-error )
which can be pretty annoying when you're trying to handle them with any modern event-delegation-y technique.
This uses event capturing on supported browsers to trigger a standard bubble-friendly event on the element in question, so you can handle th…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//image error events don't bubble, so we use | |
// native event capturing, where supported | |
if (document.addEventListener && !document.bubbleErrors) { | |
document.addEventListener('error', function (event) { | |
jQuery(event.target).trigger(event); //bubble it ourselves! | |
}, true); //true = use event capturing (not bubbling) | |
document.bubbleErrors = true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment