SVG click event delegation not firing when using defs

SVG click event delegation not firing when using defs

I have come across an interesting bug (?) whereby if you embed an SVG using ‘defs’ as part of a link (an icon for example) – clicking the icon itself does not register a click event in jQuery, but clicking the text does. 

I think this is due to SVG events not bubbling up?

If you embed the SVG directly, the link triggers regardless of whether you click the text or the icon.

Interestingly, it seems to fire if you use $('.element').click(function(){ ... }) rather than $(document).on('click', '.element', function(){ ... });

A simple test case I created can be seen here: SVG defs bug test case

    • Topic Participants

    • paul