From 5b5fb3e32de12b524430d34744cecb37ffca527b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Thu, 7 May 2015 23:07:55 +0200 Subject: [PATCH] Fix profiler details for jquery - on --- front/src/js/directives/offendersDirectives.js | 4 +++- lib/tools/phantomas/custom_modules/modules/jQYLT/jQYLT.js | 8 +++++++- test/www/jquery-page.html | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/front/src/js/directives/offendersDirectives.js b/front/src/js/directives/offendersDirectives.js index c22eed8..9ef94b2 100644 --- a/front/src/js/directives/offendersDirectives.js +++ b/front/src/js/directives/offendersDirectives.js @@ -346,7 +346,9 @@ case 'jQuery - on': case 'jQuery - one': - if (args[1]) { + if (isStringOfObject(args[0])) { + return '' + args[0].replace(/"\(function\)"/g, '(function)') + ''; + } else if (args[1] && isPureString(args[1])) { return 'bind ' + args[0] + ' on ' + getJQueryContextButtonHTML(ctxt, onASingleLine) + '\'s children filtered by ' + args[1] + ''; } else { return 'bind ' + args[0] + ' on ' + getJQueryContextButtonHTML(ctxt, onASingleLine); diff --git a/lib/tools/phantomas/custom_modules/modules/jQYLT/jQYLT.js b/lib/tools/phantomas/custom_modules/modules/jQYLT/jQYLT.js index f2403a8..c29b85a 100644 --- a/lib/tools/phantomas/custom_modules/modules/jQYLT/jQYLT.js +++ b/lib/tools/phantomas/custom_modules/modules/jQYLT/jQYLT.js @@ -274,7 +274,6 @@ exports.module = function(phantomas) { args = [].slice.call(arguments); args.forEach(function(arg, index) { - if (arg instanceof Array) { arg = '[Array]'; } @@ -296,6 +295,13 @@ exports.module = function(phantomas) { } else { try { + + for (var key in arg) { + if (typeof arg[key] === 'function') { + arg[key] = '(function)'; + } + } + arg = JSON.stringify(arg); } catch(e) { arg = '[Object]'; diff --git a/test/www/jquery-page.html b/test/www/jquery-page.html index 2e29bbe..34f53cc 100644 --- a/test/www/jquery-page.html +++ b/test/www/jquery-page.html @@ -102,6 +102,7 @@ $tbodytr.on('click', handler); $tbody.on('click', 'tr', handler); $tbody.on('click', {someData: 'Joe'}, handler); + $tbody.on({event1: handler, event2: handler}); $tbodytr.off('click', handler); $tbodytr.off('click', 'tr'); $tbodytr.off('click');