In my application, I intercept clicks on links and turn them into AJAX calls in order to achieve Single-Page-App-iness. In jQuery this looks something like this:
$('#main').on('click', 'a[href]', function(e) {
if (e.which == 2 || e.metaKey) return; // don't capture new tab clicks
/* stuff */
});
Recently, however, I have begun using Custom Elements and Shadow DOM. The above code doesn't work on a
tags which are in shadow trees, as the click event gets retargeted to the shadow host.
Is it possible to make the above code to work in order to intercept click events that occur in a shadow tree? If not, what is a best practice to continue to achieve this functionality?
Note: I am using Polymer Platform to polyfill Web Components (though not full Polymer).