Переглянути джерело

Fix profiler details for jquery - on

Gaël Métais 10 роки тому
батько
коміт
5b5fb3e32d

+ 3 - 1
front/src/js/directives/offendersDirectives.js

@@ -346,7 +346,9 @@
 
             case 'jQuery - on':
             case 'jQuery - one':
-                if (args[1]) {
+                if (isStringOfObject(args[0])) {
+                    return '<b>' + args[0].replace(/&quot;\(function\)&quot;/g, '(function)') + '</b>';
+                } else if (args[1] && isPureString(args[1])) {
                     return 'bind <b>' + args[0] + '</b> on ' + getJQueryContextButtonHTML(ctxt, onASingleLine) + '\'s children filtered by <b>' + args[1] + '</b>';
                 } else {
                     return 'bind <b>' + args[0] + '</b> on ' + getJQueryContextButtonHTML(ctxt, onASingleLine);

+ 7 - 1
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]';

+ 1 - 0
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');