From 99da8fc97f5de84a2602d7d261b6deb627cf8bd6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Manuel=20Carrasco=20Mo=C3=B1ino?= Date: Mon, 23 Dec 2013 19:06:45 +0100 Subject: [PATCH] FallBack to dummy implementation in IE8 IE9 --- .../gwt/query/client/impl/ConsoleBrowser.java | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/ConsoleBrowser.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/ConsoleBrowser.java index ec63c852..1ccc04d6 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/ConsoleBrowser.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/ConsoleBrowser.java @@ -31,7 +31,11 @@ public class ConsoleBrowser implements Console { private static class ConsoleIe8 extends ConsoleIe9 { @Override protected native void init()/*-{ - Function.prototype.call.call($wnd.console.log, $wnd.console, Array.prototype.slice.call(arguments)); + try { + Function.prototype.call.call($wnd.console.log, $wnd.console, Array.prototype.slice.call(arguments)); + } catch(e) { + this.@com.google.gwt.query.client.impl.ConsoleBrowser.ConsoleIe9::initFallBack()(); + } }-*/; } @@ -39,15 +43,33 @@ public class ConsoleBrowser implements Console { * See: http://whattheheadsaid.com/2011/04/internet-explorer-9s-problematic-console-object */ private static class ConsoleIe9 extends ConsoleImpl { + public ConsoleIe9(){ init(); } protected native void init()/*-{ + try { [ "log", "info", "warn", "error", "dir", "clear", "profile", "profileEnd" ] .forEach(function(method) { $wnd.console[method] = this.call($wnd.console[method], $wnd.console); }, Function.prototype.bind); + } catch(e) { + this.@com.google.gwt.query.client.impl.ConsoleBrowser.ConsoleIe9::initFallBack()(); + } + }-*/; + + /** + * Dummy implementation of console if IE8 or IE9 fail using dev tools. + */ + private native void initFallBack() /*-{ + if (!$wnd.console || !$wnd.console.log) { + $wnd.console = {}; + [ "log", "info", "warn", "error", "dir", "clear", "profile", "profileEnd" ] + .forEach(function(method) { + $wnd.console[method] = function(){}; + }); + } }-*/; @Override -- 2.39.5