I have what seems like a basic question, but may be more complex. I've been writing JavaScript for many years now, but never actually ran into a situation like this before so I'm curious...
Let's say there is a website that has many different developers working on many different JavaScript files. As you're using the website, you notice that a clickable link (that should be clickable) no longer works- as if it was purposefully prevented via JavaScript. Without manually going through the filesystem, how would you find what/where it is being prevented?
I've thought about this myself and the only thing I could come up with is the Chrome DevTools step feature and step through everything that happens on click of the link until you find what blocks it, but that could still be time consuming if there is a lot of functionality tied to the link.
Let's look at two actual code snippets to visualize the problem.
Here is an example link in the HTML:
<a id="the-link" href="https://example.com">Do Something</a>
Here's one way of stopping the link click in vanilla JS:
document.getElementById('the-link').addEventListener('click', function(e){
e.preventDefault();
});
That JS code could be anywhere... so how would you find it?
What if that code was using jQuery? That makes the DevTools step feature even more convoluted because it needs to step through both jQuery() and on()- not to mention any other functionality that also listens for the click event.
jQuery('#the-link').on('click', function(){
return false;
});
I'm curious how others would approach this...