Skip to content

Instantly share code, notes, and snippets.

@godmar
Created July 18, 2013 14:43
Show Gist options
  • Save godmar/6029903 to your computer and use it in GitHub Desktop.
Save godmar/6029903 to your computer and use it in GitHub Desktop.
Patch for console._window problem
--- index.js.bad 2013-07-18 10:36:04.355114831 -0400
+++ index.js 2013-07-18 10:39:47.540221548 -0400
@@ -146,7 +146,8 @@
return href;
};
- var window = this.console._window = this;
+ var window = this;
+ this.console = new Console(this);
/* Location hash support */
this.location.__defineGetter__("hash", function() {
@@ -196,6 +197,17 @@
this.__stopAllTimers = stopAllTimers;
}
+ function Console(window) {
+ this._window = window;
+ }
+
+ Console.prototype = {
+ log: function(message) { this._window.raise('log', message) },
+ info: function(message) { this._window.raise('info', message) },
+ warn: function(message) { this._window.raise('warn', message) },
+ error: function(message) { this._window.raise('error', message) }
+ };
+
DOMWindow.prototype = {
__proto__: dom,
// This implements window.frames.length, since window.frames returns a
@@ -293,12 +305,6 @@
return cs;
},
- console: {
- log: function(message) { this._window.raise('log', message) },
- info: function(message) { this._window.raise('info', message) },
- warn: function(message) { this._window.raise('warn', message) },
- error: function(message) { this._window.raise('error', message) }
- },
navigator: {
userAgent: 'Node.js (' + process.platform + '; U; rv:' + process.version + ')',
appName: 'Node.js jsDom',
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment