You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2014/12/29 23:37:29 UTC

[2/2] tapestry-5 git commit: Some further changes to address IE8 compatibility

Some further changes to address IE8 compatibility


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/ffeaabc0
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/ffeaabc0
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/ffeaabc0

Branch: refs/heads/master
Commit: ffeaabc0413a5c8e9fa4a17e7fe8058d2903d240
Parents: 9769b0d
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Mon Dec 29 14:12:52 2014 -0800
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Mon Dec 29 14:12:52 2014 -0800

----------------------------------------------------------------------
 .../META-INF/modules/t5/core/console.coffee     | 37 ++++++++++----------
 1 file changed, 19 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/ffeaabc0/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/console.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/console.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/console.coffee
index ab7ccc2..b0785ca 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/console.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/console.coffee
@@ -1,5 +1,3 @@
-# Copyright 2012-2013 The Apache Software Foundation
-#
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
@@ -18,7 +16,14 @@
 define ["./dom", "underscore", "./bootstrap"],
   (dom, _, { glyph }) ->
 
-    nativeConsole = {}
+    nativeConsole = null
+
+    try
+      # FireFox will throw an exception if you even access the console object and it does
+      # not exist. Wow!
+      nativeConsole = window.console or {}
+    catch e
+
     floatingConsole = null
     messages = null
 
@@ -53,13 +58,6 @@ define ["./dom", "underscore", "./bootstrap"],
         </button>
       """
 
-
-    try
-      # FireFox will throw an exception if you even access the console object and it does
-      # not exist. Wow!
-      nativeConsole = console
-    catch e
-
     # _internal_: displays the message inside the floating console, creating the floating
     # console as needed.
     display = (className, message) ->
@@ -153,17 +151,17 @@ define ["./dom", "underscore", "./bootstrap"],
 
           return unless forceFloating
 
-        if _.isFunction consolefn
+        if window.console and (_.isFunction consolefn)
           # Use the available native console, calling it like an instance method
-          consolefn.call console, message
+          consolefn.call window.console, message
           return
 
-        # On IE8, the console object appears empty unless debugging tools are enabled.
-        return unless consolefn
-
         # And IE just has to be different. The properties of console are callable, like functions,
         # but aren't proper functions that work with `call()` either.
-        consolefn message
+        # On IE8, the console object is undefined unless debugging tools are enabled.
+        # In that case, nativeConsole will be an empty object.
+        if consolefn
+          consolefn message
 
         return
 
@@ -176,13 +174,16 @@ define ["./dom", "underscore", "./bootstrap"],
       # in production mode).
       debugEnabled: (document.documentElement.getAttribute "data-debug-enabled")?
 
+    noop = ->
+
     # When debugging is not enabled, then the debug function becomes a no-op.
     exports.debug =
       if exports.debugEnabled
         # If native console available, go for it.  IE doesn't have debug, so we use log instead.
-        level "debug", (nativeConsole.debug or nativeConsole.log)
+        # Add a special noop case for IE8, since IE8 is just crazy.
+        level "debug", (nativeConsole.debug or nativeConsole.log or noop)
       else
-        ->
+        noop
 
     # This is also an aid to debugging; it allows arbitrary scripts to present on the console; when using Geb
     # and/or Selenium, it is very useful to present debugging data right on the page.