-
-
Save sedoyjan/6cfba5ae749f62da3b7256eb6bf9287d to your computer and use it in GitHub Desktop.
Revisions
-
danburzo revised this gist
Dec 10, 2014 . 2 changed files with 30 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -10,4 +10,6 @@ var items = Array.prototype.slice.call( }; }).filter(function(item) { return item.listeners.length; }); // See below for things you can do with the items 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ // Things you can do with the items // 1. log them to the console console.log(items); // 2. Put a red border around the elements items.forEach(function(item) { item.element.style.outline = '1px solid red'; }) // 3. generate a summary var summary = .map(function(item) { var el = item.element, id = el.id, className = el.className; if (className instanceof SVGAnimatedString) { className = className.baseVal; } var str = el.tagName.toLowerCase() + (id ? '#' + id : '') + (className ? '.' + className.replace(/\s+/g, '.') : ''); str += ' ' + item.listeners.map(function(l) { return l.event + ': ' + l.listeners.length; }).join(' '); return str; }).join('\n'); console.log(summary); -
danburzo revised this gist
Dec 10, 2014 . 1 changed file with 9 additions and 9 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,13 @@ var items = Array.prototype.slice.call( document.querySelectorAll('*') ).map(function(element) { var listeners = getEventListeners(element); return { element: element, listeners: Object.keys(listeners).map(function(k) { return { event: k, listeners: listeners[k] }; }) }; }).filter(function(item) { return item.listeners.length; }); -
danburzo revised this gist
Dec 10, 2014 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,9 @@ var items = Array.prototype.slice.call( document.querySelectorAll('*') ).map(function(element) { var listeners = getEventListeners(element); return { element: element, listeners: Object.keys(listeners).map(function(k) { return { event: k, listeners: listeners[k] }; }) -
danburzo revised this gist
Dec 10, 2014 . 1 changed file with 11 additions and 8 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,13 @@ Array.prototype.slice.call( document.querySelectorAll('*') ).map(function(el) { var listeners = getEventListeners(el); return { element: el, listeners: Object.keys(listeners).map(function(k) { return { event: k, listeners: listeners[k] }; }) }; }).filter(function(item) { return item.listeners.length; }); -
danburzo revised this gist
Feb 27, 2014 . 1 changed file with 10 additions and 12 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,10 @@ Array.prototype.slice.call( document.querySelectorAll('*') ).map(function(el) { return { element: el, listeners: getEventListeners(el) }; }).filter(function(o) { return Object.keys(o.listeners).length > 0; }); -
danburzo created this gist
Feb 27, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ function eventListeners(rootElement) { return Array.prototype.slice.call( (rootElement || document).querySelectorAll('*') ).map(function(el) { return { element: el, listeners: getEventListeners(el) }; }).filter(function(o) { return Object.keys(o.listeners).length > 0; }); };