素人がプログラミングを勉強していたブログ

プログラミング、セキュリティ、英語、Webなどのブログ since 2008

連絡先: すかいぷ:javascripter_  か javascripter あっと tsukkun.net skypeのほうがいいです

今日のFirebugパッチ

console.log.call(null, 'hoge');

のように、thisをconsole以外にした時にthis.notifyFirebugが存在しないというエラーになるので、それを直す。

--- consoleInjected.js.backup	2008-11-04 22:17:10.000000000 +0900
+++ consoleInjected.js	2008-11-04 22:19:12.000000000 +0900
@@ -1,24 +1,25 @@
 /* See license.txt for terms of usage */
 function _FirebugConsole()
 {
-    this.log = function() { this.notifyFirebug(arguments, 'log', 'firebugAppendConsole'); }
-    this.debug = function() { this.notifyFirebug(arguments, 'debug', 'firebugAppendConsole'); }
-    this.info = function() { this.notifyFirebug(arguments, 'info', 'firebugAppendConsole'); }
-    this.warn = function() { this.notifyFirebug(arguments, 'warn', 'firebugAppendConsole'); }
-    this.error = function() { this.notifyFirebug(arguments, 'error', 'firebugAppendConsole'); }
-    this.assert = function() { this.notifyFirebug(arguments, 'assert', 'firebugAppendConsole'); }
-    this.dir = function() { this.notifyFirebug(arguments, 'dir', 'firebugAppendConsole'); }
-    this.dirxml = function() { this.notifyFirebug(arguments, 'dirxml', 'firebugAppendConsole'); }
-    this.trace = function() { this.notifyFirebug(arguments, 'trace', 'firebugAppendConsole'); }
-    this.group = function() { this.notifyFirebug(arguments, 'group', 'firebugAppendConsole'); }
-    this.groupEnd = function() { this.notifyFirebug(arguments, 'groupEnd', 'firebugAppendConsole'); }
-    this.groupCollapsed = function() { this.notifyFirebug(arguments, 'groupCollapsed', 'firebugAppendConsole'); }
-    this.time = function() { this.notifyFirebug(arguments, 'time', 'firebugAppendConsole'); }
-    this.timeEnd = function() { this.notifyFirebug(arguments, 'timeEnd', 'firebugAppendConsole'); }
-    this.profile = function() { this.notifyFirebug(arguments, 'profile', 'firebugAppendConsole'); }
-    this.profileEnd = function() { this.notifyFirebug(arguments, 'profileEnd', 'firebugAppendConsole'); }
-    this.count = function() { this.notifyFirebug(arguments, 'count', 'firebugAppendConsole'); }
-    this.clear = function() { this.notifyFirebug(arguments, 'clear', 'firebugAppendConsole'); }
+    var self = this;
+    this.log = function() { self.notifyFirebug(arguments, 'log', 'firebugAppendConsole'); }
+    this.debug = function() { self.notifyFirebug(arguments, 'debug', 'firebugAppendConsole'); }
+    this.info = function() { self.notifyFirebug(arguments, 'info', 'firebugAppendConsole'); }
+    this.warn = function() { self.notifyFirebug(arguments, 'warn', 'firebugAppendConsole'); }
+    this.error = function() { self.notifyFirebug(arguments, 'error', 'firebugAppendConsole'); }
+    this.assert = function() { self.notifyFirebug(arguments, 'assert', 'firebugAppendConsole'); }
+    this.dir = function() { self.notifyFirebug(arguments, 'dir', 'firebugAppendConsole'); }
+    this.dirxml = function() { self.notifyFirebug(arguments, 'dirxml', 'firebugAppendConsole'); }
+    this.trace = function() { self.notifyFirebug(arguments, 'trace', 'firebugAppendConsole'); }
+    this.group = function() { self.notifyFirebug(arguments, 'group', 'firebugAppendConsole'); }
+    this.groupEnd = function() { self.notifyFirebug(arguments, 'groupEnd', 'firebugAppendConsole'); }
+    this.groupCollapsed = function() { self.notifyFirebug(arguments, 'groupCollapsed', 'firebugAppendConsole'); }
+    this.time = function() { self.notifyFirebug(arguments, 'time', 'firebugAppendConsole'); }
+    this.timeEnd = function() { self.notifyFirebug(arguments, 'timeEnd', 'firebugAppendConsole'); }
+    this.profile = function() { self.notifyFirebug(arguments, 'profile', 'firebugAppendConsole'); }
+    this.profileEnd = function() { self.notifyFirebug(arguments, 'profileEnd', 'firebugAppendConsole'); }
+    this.count = function() { self.notifyFirebug(arguments, 'count', 'firebugAppendConsole'); }
+    this.clear = function() { self.notifyFirebug(arguments, 'clear', 'firebugAppendConsole'); }
 
     this.notifyFirebug = function(objs, methodName, eventID)
     {
@@ -79,4 +80,4 @@
     }
     return element;
 };
- 
\ No newline at end of file
+