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 2012/10/03 23:58:50 UTC
[1/3] git commit: Fix a number of page-initialization problems that
only manifest under IE
Updated Branches:
refs/heads/5.4-js-rewrite 654f3ef1a -> 9001a1e3c
Fix a number of page-initialization problems that only manifest under IE
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/9001a1e3
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/9001a1e3
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/9001a1e3
Branch: refs/heads/5.4-js-rewrite
Commit: 9001a1e3c2642c51550def85cde24cc31f96248e
Parents: 5f62f25
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Wed Oct 3 14:52:42 2012 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Wed Oct 3 14:52:42 2012 -0700
----------------------------------------------------------------------
.../META-INF/modules/core/console.coffee | 26 +++++++++-----
.../coffeescript/META-INF/modules/core/spi.coffee | 15 +++++---
.../resources/org/apache/tapestry5/t5-pubsub.js | 7 +++-
3 files changed, 32 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/9001a1e3/tapestry-core/src/main/coffeescript/META-INF/modules/core/console.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/core/console.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/core/console.coffee
index f8643ee..6f61807 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/core/console.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/core/console.coffee
@@ -58,23 +58,31 @@ define ["core/spi", "core/builder", "_"], (spi, builder, _) ->
level = (className, consolefn) ->
(message) ->
- # consolefn may be null if there's no console; under IE it may be non-null, but not a function
- if _.isFunction consolefn
- # Use the available native console
- consolefn.call(console, message)
- else
+ # consolefn may be null if there's no console; under IE it may be non-null, but not a function.
+ unless consolefn
# Display it floating. If there's a real problem, such as a failed Ajax request, then the
# client-side code should be alerting the user in some other way, and not rely on them
# being able to see the logged console output.
display className, message
+ return
+
+ if _.isFunction consolefn
+ # Use the available native console, calling it like an instance method
+ consolefn.call console, message
+ else
+ # 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
return
- # If native console available, go for it
+ # If native console available, go for it. IE doesn't have debug, so we use log instead.
- exports[name] = level("t-#{name}", nativeConsole[name]) for name in ["debug", "info", "warn"]
- exports.error = level("t-err", nativeConsole.error)
+ exports.debug = level "t-debug", (nativeConsole.debug or nativeConsole.log)
+ exports.info = level "t-info", nativeConsole.info
+ exports.warn = level "t-warn", nativeConsole.warn
+ exports.error = level "t-err", nativeConsole.error
# Return the exports; we keep a reference to it, so we can see exports.DURATION, even
- # if someone else modifies it.
+ # if some other module imports this one and modified that property.
return exports
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/9001a1e3/tapestry-core/src/main/coffeescript/META-INF/modules/core/spi.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/core/spi.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/core/spi.coffee
index 28f7fee..b189c3d 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/core/spi.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/core/spi.coffee
@@ -31,10 +31,6 @@
# the SPI and gain the valuable benefit of not caring about the infrastructure framework.
define ["_", "prototype"], (_) ->
- # It is useful in the `exports.domLoaded` function to know when the DOM has in fact been loaded.
- domLoaded = false
- $(document).observe "dom:loaded", -> domLoaded = true
-
# _internal_: splits the string into words separated by whitespace
split = (str) ->
_(str.split " ").reject (s) -> s is ""
@@ -472,7 +468,14 @@ define ["_", "prototype"], (_) ->
# Returns this module's exports, for chained calls. If the DOM has already loaded, the callback is invoked
# immediately.
domReady: (callback) ->
- if domLoaded
+ # Hack for IE, which doesn't fire the dom:loaded event reliably. However, we know that any code here
+ # is invoked from the footer of the document, so the rest can be assumed to be loaded.
+
+ if Prototype.Browser.IE
+ document.loaded = true
+
+ # Prototype sets this property when the document is loaded.
+ if document.loaded
callback()
else
$(document).observe "dom:loaded", callback
@@ -503,7 +506,7 @@ define ["_", "prototype"], (_) ->
# Returns a wrapped version of the document.body element. Care must be take to not invoke this function before the
# body element exists; typically only after the DOM has loaded, such as a `domReady()` callback.
body: ->
- throw new Error "May not access body until after DOM has loaded." unless domLoaded
+ throw new Error "May not access body until after DOM has loaded." unless document.loaded
bodyWrapper ?= (wrapElement document.body)
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/9001a1e3/tapestry-core/src/main/resources/org/apache/tapestry5/t5-pubsub.js
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/t5-pubsub.js b/tapestry-core/src/main/resources/org/apache/tapestry5/t5-pubsub.js
index 836a97f..a622fac 100644
--- a/tapestry-core/src/main/resources/org/apache/tapestry5/t5-pubsub.js
+++ b/tapestry-core/src/main/resources/org/apache/tapestry5/t5-pubsub.js
@@ -28,7 +28,12 @@ define("core/compat/t5-pubsub", ["core/compat/t5"], function () {
// Necessary since T5.dom depends on T5.pubsub
function $(element) {
- return T5.$(element);
+ // Note: duplicates code from t5-dom.js (T5.dom.locate).
+ if (_.isString(element)) {
+ return document.getElementById(element);
+ }
+
+ return element; // may be null, otherwise presumed to be a DOM node
}
function purgePublisherCache(topic) {