DataTables / VisualEvent

Visually show Javascript events on a page
http://sprymedia.co.uk
1.04k stars 162 forks source link

Added funcObject support for jQuery parser #59

Closed igui closed 4 years ago

igui commented 9 years ago

This is a tentative pull request to add support in VisualEvent for getting the original function objects in addition to the current function source.

Why this? Because I'm investigating the event listeners attached to invisible elements, which are not visible in the VisualEvent UI. Since you can't interact with them using the UI, you can't get event handler function definition AFAIK

I got the idea to have the original function object, attached to the listener object the parser return. This is very convenient because in modern browsers you can inspect function object properties like it's prototype, name, number of arguments, etc.

The way of accessing the hidden elements using the VisualEvent instance and filter them. For example, if jQuery is available you can do the following to get them.

var invisible = VisualEvent.instance.s.elements.filter(function(el){ return jQuery(el.node).is(':not(:visible)') })

I made this change only for the jQuery.js parser, only to showcase it. If you like the idea I can go further and apply this change for the other parsers.

DataTables commented 9 years ago

Nice - yes - I like this a lot. I've long wanted to add a mode whereby you can click an option and it will show you a table of all the event listeners in the page. Sort of a non-visual event :-)

igui commented 9 years ago

Cool :+1: I will make a commit on the rest of the parsers.

igui commented 4 years ago

I will close the PR given it's been around for five years. Sorry :pray: