You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2012/08/14 03:33:15 UTC
[7/11] git commit: Correctly support domReady() callbacks when the
DOM is already ready
Correctly support domReady() callbacks when the DOM is already ready
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/f93bf63b
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/f93bf63b
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/f93bf63b
Branch: refs/heads/5.4-js-rewrite
Commit: f93bf63bd87f3b3d18942f0ccd3e82e3b3b2335a
Parents: 579d7ff
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Mon Aug 13 15:34:09 2012 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Mon Aug 13 15:34:09 2012 -0700
----------------------------------------------------------------------
.../coffeescript/META-INF/modules/core/spi.coffee | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/f93bf63b/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 26c12d5..e85723d 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
@@ -20,6 +20,10 @@
# Prototype ... but does it in a way that makes it relatively easy to swap in jQuery instead.
define ["_", "prototype"], (_) ->
+ # When the document has loaded, convert `domReady` to just execute the callback immediately.
+ $(document).observe "dom:loaded", ->
+ exports.domReady = (callback) -> callback()
+
# _internal_: splits the string into words separated by whitespace
split = (str) ->
_(str.split " ").reject (s) -> s is ""
@@ -270,6 +274,13 @@ define ["_", "prototype"], (_) ->
else
return null
+ # Finds all child elements matching the CSS selector, returning them
+ # as an array of ElementWrappers.
+ findAll: (selector) ->
+ matches = @element.select selector
+
+ _.map matches, (e) -> new ElementWrapper e
+
# Returns an ElementWrapper for this element's containing element. The ElementWrapper is created lazily, and
# cached. Returns null if this element has no parentNode (either because this element is the document object, or
# because this element is not yet attached to the DOM).
@@ -401,7 +412,7 @@ define ["_", "prototype"], (_) ->
# still be in-transit). This is a safe time to search the DOM, modify attributes, and attach event handlers.
# Returns this modules exports, for chained calls.
domReady: (callback) ->
- document.observe "dom:loaded", callback
+ $(document).observe "dom:loaded", callback
exports