diff options
author | Manuel Carrasco Moñino <manuel.carrasco.m@gmail.com> | 2013-12-23 19:06:45 +0100 |
---|---|---|
committer | Manuel Carrasco Moñino <manuel.carrasco.m@gmail.com> | 2013-12-23 19:06:45 +0100 |
commit | 99da8fc97f5de84a2602d7d261b6deb627cf8bd6 (patch) | |
tree | 665f2593549f636c812af9d5406806587e2c48f2 | |
parent | 1ddff6749a60c10f25b89feccc01a70c6d92db72 (diff) | |
download | gwtquery-99da8fc97f5de84a2602d7d261b6deb627cf8bd6.tar.gz gwtquery-99da8fc97f5de84a2602d7d261b6deb627cf8bd6.zip |
FallBack to dummy implementation in IE8 IE9
-rw-r--r-- | gwtquery-core/src/main/java/com/google/gwt/query/client/impl/ConsoleBrowser.java | 24 |
1 files changed, 23 insertions, 1 deletions
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 |