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/03 23:33:10 UTC

[3/10] git commit: Rework more of the existing JavaScript libraries to be compatible with the RequireJS modules

Rework more of the existing JavaScript libraries to be compatible with the RequireJS modules


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

Branch: refs/heads/5.4-js-rewrite
Commit: a0fc10935230a5991cd751a5d75aff55363d66b2
Parents: 87952d5
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Fri Aug 3 11:30:40 2012 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Fri Aug 3 11:30:40 2012 -0700

----------------------------------------------------------------------
 .../META-INF/modules/core/pageinit.coffee          |   71 ++--
 .../services/javascript/CoreJavaScriptStack.java   |   61 ++-
 .../main/resources/org/apache/tapestry5/t5-ajax.js |  216 ++++----
 .../resources/org/apache/tapestry5/t5-alerts.js    |  199 ++++---
 .../resources/org/apache/tapestry5/t5-console.js   |    8 +-
 .../main/resources/org/apache/tapestry5/t5-core.js |  162 +++---
 .../main/resources/org/apache/tapestry5/t5-dom.js  |  234 ++++----
 .../resources/org/apache/tapestry5/t5-events.js    |   46 +-
 .../org/apache/tapestry5/t5-formfragment.js        |  157 +++---
 .../main/resources/org/apache/tapestry5/t5-init.js |   39 +-
 .../resources/org/apache/tapestry5/t5-prototype.js |   62 ++-
 .../resources/org/apache/tapestry5/t5-pubsub.js    |  425 ++++++++-------
 .../main/resources/org/apache/tapestry5/t5-spi.js  |   96 ++--
 .../org/apache/tapestry5/tapestry-console.js       |   16 +-
 .../org/apache/tapestry5/tapestry-debug.js         |   18 +
 .../org/apache/tapestry5/tapestry-messages.js      |   33 +-
 .../org/apache/tapestry5/tapestry-messages_de.js   |   32 +-
 .../apache/tapestry5/tapestry-messages_fi_FI.js    |   78 ++--
 .../resources/org/apache/tapestry5/tapestry.js     |    2 +-
 .../main/resources/org/apache/tapestry5/tree.js    |  257 +++++-----
 20 files changed, 1164 insertions(+), 1048 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a0fc1093/tapestry-core/src/main/coffeescript/META-INF/modules/core/pageinit.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/core/pageinit.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/core/pageinit.coffee
index 2330208..1ac93a2 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/core/pageinit.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/core/pageinit.coffee
@@ -55,23 +55,23 @@ define ["_", "core/console"], (_, console) ->
     head = document.head or document.getElementsByTagName("head")[0]
 
     _.chain(newStylesheets)
-      .map((ss) -> { href: rebuildURL(ss.href), media: ss.media })
-      .reject((ss) -> loaded.contains(ss.href).value())
-      .each((ss) ->
-        element = document.createElement "link"
-        element.setAttribute "type", "text/css"
-        element.setAttribute "rel", "stylesheet"
-        element.setAttribute "href", ss.href
-        if ss.media
-          element.setAttribute "media", ss.media
-
-        if insertionPoint
-          head.insertBefore element, insertionPoint.ownerNode
-        else
-          head.appendChild element
-
-        console.debug "Added stylesheet #{ss.href}"
-      )
+    .map((ss) -> { href: rebuildURL(ss.href), media: ss.media })
+    .reject((ss) -> loaded.contains(ss.href).value())
+    .each((ss) ->
+      element = document.createElement "link"
+      element.setAttribute "type", "text/css"
+      element.setAttribute "rel", "stylesheet"
+      element.setAttribute "href", ss.href
+      if ss.media
+        element.setAttribute "media", ss.media
+
+      if insertionPoint
+        head.insertBefore element, insertionPoint.ownerNode
+      else
+        head.appendChild element
+
+      console.debug "Added stylesheet #{ss.href}"
+    )
 
     return
 
@@ -128,7 +128,8 @@ define ["_", "core/console"], (_, console) ->
         # This is where we want to get:
         # require ["core/domReady!"], -> exports.initialize otherInits
         # But for compatibility, this is what we're stuck with:
-        Tapestry.onDOMLoaded -> exports.initialize otherInits
+        require ["core/compat/tapestry"], ->
+          Tapestry.onDOMLoaded -> exports.initialize otherInits
 
     evalJavaScript: (js) ->
       console.debug "Evaluating: #{js}"
@@ -160,26 +161,30 @@ define ["_", "core/console"], (_, console) ->
 
       addStylesheets partial?.stylesheets
 
-      # Make sure all libraries are loaded
-      exports.loadScripts partial?.libraries, ->
+      # Temporary ugliness: ensuring Tapestry is available since we, for the moment,
+      # make use of some of it.
+      require ["core/compat/tapestry"], ->
+        # Make sure all libraries are loaded
+        exports.loadScripts partial?.libraries, ->
 
-        # Libraries are loaded, update each zone:
-        _(partial?.content).each ([id, content]) ->
-          # Looking forward to stripping out thie ZoneManager nonsense
-          console.debug "Updating content for zone #{id}"
+          # Libraries are loaded, update each zone:
+          _(partial?.content).each ([id, content]) ->
+            console.debug "Updating content for zone #{id}"
 
-          zoneMgr = Tapestry.findZoneManagerForZone id
+            # Looking forward to stripping out this ZoneManager nonsense
 
-          zoneMgr && zoneMgr.show content
+            zoneMgr = Tapestry.findZoneManagerForZone id
 
-        # Invoke the callback, if present.  The callback may do its own content updates.
-        callback and callback.call context, response
+            zoneMgr && zoneMgr.show content
 
-        # Now that all content updates are, presumably, complete, it is time to
-        # perform initializations.  Once those complete, use the onDomLoadedCallback()
-        # to do some final changes and event registrations (hopefully, to be removed
-        # soon).
+          # Invoke the callback, if present.  The callback may do its own content updates.
+          callback and callback.call context, response
 
-        exports.initialize partial?.inits, Tapestry.onDomLoadedCallback
+          # Now that all content updates are, presumably, complete, it is time to
+          # perform initializations.  Once those complete, use the onDomLoadedCallback()
+          # to do some final changes and event registrations (hopefully, to be removed
+          # soon).
+
+          exports.initialize partial?.inits, Tapestry.onDomLoadedCallback
 
       return

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a0fc1093/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/CoreJavaScriptStack.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/CoreJavaScriptStack.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/CoreJavaScriptStack.java
index c07802d..8a4c971 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/CoreJavaScriptStack.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/CoreJavaScriptStack.java
@@ -18,9 +18,9 @@ import org.apache.tapestry5.Asset;
 import org.apache.tapestry5.SymbolConstants;
 import org.apache.tapestry5.func.F;
 import org.apache.tapestry5.func.Flow;
+import org.apache.tapestry5.func.Mapper;
 import org.apache.tapestry5.internal.TapestryInternalUtils;
 import org.apache.tapestry5.ioc.annotations.Symbol;
-import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
 import org.apache.tapestry5.ioc.services.SymbolSource;
 import org.apache.tapestry5.ioc.services.ThreadLocale;
 import org.apache.tapestry5.services.AssetSource;
@@ -38,15 +38,13 @@ import java.util.Locale;
  */
 public class CoreJavaScriptStack implements JavaScriptStack
 {
-    private final boolean productionMode;
-
     private final SymbolSource symbolSource;
 
     private final AssetSource assetSource;
 
     private final ThreadLocale threadLocale;
 
-    private final List<Asset> javaScriptStack, stylesheetStack;
+    private final Flow<Asset> javaScriptStack, stylesheetStack;
 
     private static final String ROOT = "org/apache/tapestry5";
 
@@ -54,18 +52,32 @@ public class CoreJavaScriptStack implements JavaScriptStack
             {
                     // Core scripts added to any page that uses scripting
 
+                    // TODO: Only include prototype based on configuration
                     "${tapestry.scriptaculous}/prototype.js",
 
+
+                    // TODO: Only include these two when in compatibility mode ...
+                    // after the t5-* and tapestry libraries have been stripped
+                    // of Scriptaculous code.
+
                     "${tapestry.scriptaculous}/scriptaculous.js",
 
                     "${tapestry.scriptaculous}/effects.js",
 
-                    // Below uses functions defined by the prior three.
+                    // TODO: Include jQuery based on configuration
+
+                    // TODO: Possibly extract prototype/scriptaculous/jquery from the stack
+                    // (as has been done with Underscore), and convert to a shimmed module.
+
+                    // Below uses functions defined by the above.
 
                     // Order is important, there are some dependencies
                     // going on here. Switching over to a more managed module system
                     // is starting to look like a really nice idea!
 
+                    // Update: most (all?) of these have been rewritten to use require() or define()
+                    // to help manage dependencies, but there's likely some bugs in there!
+
                     ROOT + "/t5-core.js",
 
                     ROOT + "/t5-spi.js",
@@ -118,17 +130,22 @@ public class CoreJavaScriptStack implements JavaScriptStack
             ThreadLocale threadLocale)
     {
         this.symbolSource = symbolSource;
-        this.productionMode = productionMode;
         this.assetSource = assetSource;
         this.threadLocale = threadLocale;
 
-        javaScriptStack = convertToAssets(CORE_JAVASCRIPT);
-        stylesheetStack = convertToAssets(CORE_STYLESHEET);
+        Flow<String> coreJavascript = F.flow(CORE_JAVASCRIPT);
+
+        Flow<String> javaScript = productionMode
+                ? coreJavascript
+                : coreJavascript.append(ROOT + "/tapestry-debug.js");
+
+        javaScriptStack = convertToAssets(javaScript);
+        stylesheetStack = convertToAssets(F.flow(CORE_STYLESHEET));
     }
 
     public String getInitialization()
     {
-        return productionMode ? null : "Tapestry.DEBUG_ENABLED = true;";
+        return null;
     }
 
     public List<String> getStacks()
@@ -136,16 +153,16 @@ public class CoreJavaScriptStack implements JavaScriptStack
         return Collections.emptyList();
     }
 
-    private List<Asset> convertToAssets(String[] paths)
+    private Flow<Asset> convertToAssets(Flow<String> paths)
     {
-        List<Asset> assets = CollectionFactory.newList();
-
-        for (String path : paths)
+        return paths.map(new Mapper<String, Asset>()
         {
-            assets.add(expand(path, null));
-        }
-
-        return Collections.unmodifiableList(assets);
+            @Override
+            public Asset map(String element)
+            {
+                return expand(element, null);
+            }
+        });
     }
 
     private Asset expand(String path, Locale locale)
@@ -159,17 +176,11 @@ public class CoreJavaScriptStack implements JavaScriptStack
     {
         Asset messages = assetSource.getAsset(null, ROOT + "/tapestry-messages.js", threadLocale.getLocale());
 
-        return createStack(javaScriptStack, messages).toList();
+        return javaScriptStack.append(messages).toList();
     }
 
     public List<StylesheetLink> getStylesheets()
     {
-        return createStack(stylesheetStack).map(TapestryInternalUtils.assetToStylesheetLink)
-                .toList();
-    }
-
-    private Flow<Asset> createStack(List<Asset> stack, Asset... assets)
-    {
-        return F.flow(stack).append(assets);
+        return stylesheetStack.map(TapestryInternalUtils.assetToStylesheetLink).toList();
     }
 }

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a0fc1093/tapestry-core/src/main/resources/org/apache/tapestry5/t5-ajax.js
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/t5-ajax.js b/tapestry-core/src/main/resources/org/apache/tapestry5/t5-ajax.js
index 82feced..32f024c 100644
--- a/tapestry-core/src/main/resources/org/apache/tapestry5/t5-ajax.js
+++ b/tapestry-core/src/main/resources/org/apache/tapestry5/t5-ajax.js
@@ -1,4 +1,4 @@
-/* Copyright 2011 The Apache Software Foundation
+/* Copyright 2011, 2012 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.
@@ -19,133 +19,135 @@
  * processing of Tapestry's partial page render response (a common response for
  * many types of Ajax requests).             `
  */
-T5.define("ajax", function() {
+define("core/compat/t5-ajax", ["core/compat/t5-spi"], function () {
+    T5.define("ajax", function () {
 
-    var _ = T5._;
-    var $ = T5.$;
-    var spi = T5.spi;
+        var _ = T5._;
+        var $ = T5.$;
+        var spi = T5.spi;
 
-    var exceptionContainer, iframe, iframeDocument;
+        var exceptionContainer, iframe, iframeDocument;
 
-    function noop() {
-    }
+        function noop() {
+        }
 
-    function writeToErrorIFrame(content) {
-        // Clear current content.
-        iframeDocument.open();
-        // Write in the new content.
-        iframeDocument.write(content);
-        iframeDocument.close();
+        function writeToErrorIFrame(content) {
+            // Clear current content.
+            iframeDocument.open();
+            // Write in the new content.
+            iframeDocument.write(content);
+            iframeDocument.close();
 
-    }
+        }
 
-    function resizeExceptionDialog() {
-        // Very Prototype specific!
-        var dims = document.viewport.getDimensions();
+        function resizeExceptionDialog() {
+            // Very Prototype specific!
+            var dims = document.viewport.getDimensions();
 
-        iframe.width = dims.width - 100;
-        iframe.height = dims.height - (100 + 20);
-    }
+            iframe.width = dims.width - 100;
+            iframe.height = dims.height - (100 + 20);
+        }
 
-    /**
-     * When there's a server-side failure, Tapestry sends back the exception report page as HTML.
-     * This function creates and displays a dialog that presents that content to the user using
-     * a created iframe element.
-     * @param exceptionContext HTML markup for the exception report
-     */
-    function showExceptionDialog(exceptionContent) {
+        /**
+         * When there's a server-side failure, Tapestry sends back the exception report page as HTML.
+         * This function creates and displays a dialog that presents that content to the user using
+         * a created iframe element.
+         * @param exceptionContext HTML markup for the exception report
+         */
+        function showExceptionDialog(exceptionContent) {
 
-        if (!exceptionContainer) {
-            var markup = [ "<div class='t-exception-container'>",
-                "<iframe class='t-exception-frame' width='100%'></iframe>",
-                "<div class='t-exception-controls'>",
-                "<span class='t-exception-close'>Close</span>",
-                "</div>",
-                "</div>"].join("");
+            if (!exceptionContainer) {
+                var markup = [ "<div class='t-exception-container'>",
+                    "<iframe class='t-exception-frame' width='100%'></iframe>",
+                    "<div class='t-exception-controls'>",
+                    "<span class='t-exception-close'>Close</span>",
+                    "</div>",
+                    "</div>"].join("");
 
-            exceptionContainer = T5.dom.find(T5.dom.appendMarkup(document.body, markup), 'div.t-exception-container');
+                exceptionContainer = T5.dom.find(T5.dom.appendMarkup(document.body, markup), 'div.t-exception-container');
 
-            iframe = T5.dom.find(exceptionContainer, "iframe");
+                iframe = T5.dom.find(exceptionContainer, "iframe");
 
-            // See http://xkr.us/articles/dom/iframe-document/
+                // See http://xkr.us/articles/dom/iframe-document/
 
-            iframeDocument = (iframe.contentWindow || iframe.contentDocument);
-            if (iframeDocument.document) {
-                iframeDocument = iframeDocument.document;
-            }
+                iframeDocument = (iframe.contentWindow || iframe.contentDocument);
+                if (iframeDocument.document) {
+                    iframeDocument = iframeDocument.document;
+                }
 
-            var closeButton = T5.dom.find(exceptionContainer, ".t-exception-close");
+                var closeButton = T5.dom.find(exceptionContainer, ".t-exception-close");
 
-            T5.dom.observe(closeButton, "click", function(event) {
-                event.stop();
-                writeToErrorIFrame("");
-                T5.dom.hide(exceptionContainer);
-            });
+                T5.dom.observe(closeButton, "click", function (event) {
+                    event.stop();
+                    writeToErrorIFrame("");
+                    T5.dom.hide(exceptionContainer);
+                });
 
-            // Call it now to set initial width/height.
+                // Call it now to set initial width/height.
 
-            resizeExceptionDialog();
+                resizeExceptionDialog();
 
-            // Very Prototype specific:
+                // Very Prototype specific:
+
+                // See http://groups.google.com/group/prototype-scriptaculous/browse_thread/thread/1b0ce3e94020121f/cdbab773fd8e7a4b
+                // debounced to handle the rate at which IE sends the resizes (every pixel!)
+
+                Event.observe(window, "resize", _.debounce(resizeExceptionDialog, 20));
+            }
 
-            // See http://groups.google.com/group/prototype-scriptaculous/browse_thread/thread/1b0ce3e94020121f/cdbab773fd8e7a4b
-            // debounced to handle the rate at which IE sends the resizes (every pixel!)
 
-            Event.observe(window, "resize", _.debounce(resizeExceptionDialog, 20));
+            writeToErrorIFrame(exceptionContent);
+
+            exceptionContainer.show();
+        }
+
+        function defaultFailure(transport) {
         }
 
+        function defaultException(exception) {
+        }
+
+        /**
+         * Performs an AJAX request. The options object is used to identify
+         * additional parameters to be encoded into the request, and to identify the
+         * handlers for success and failure.
+         * <p>
+         * Option keys:
+         * <dl>
+         * <dt>parameters
+         * <dd>object with string keys and string values, defines additional query
+         * parameters
+         * <dt>failure
+         * <dd>A function invoked if the Ajax request fails; the function is passed
+         * the transport
+         * <dt>exception
+         * <dd>A function invoked if there's an exception processing the Ajax
+         * request, the function is passed the exception
+         * <dt>success
+         * <dd>A function invoked when the Ajax response is returned successfully.
+         * The function is passed the transport object.
+         * <dt>method
+         * <dd>The type of request, 'get' or 'post'. 'post' is the default.
+         * </dl>
+         *
+         * @param url
+         *            the URL for the request
+         * @param options
+         *            an optional object that provides additional options.
+         * @return not defined
+         *
+         */
+        function request(url, options) {
+
+            throw "not yet implemented";
+        }
 
-        writeToErrorIFrame(exceptionContent);
-
-        exceptionContainer.show();
-    }
-
-    function defaultFailure(transport) {
-    }
-
-    function defaultException(exception) {
-    }
-
-    /**
-     * Performs an AJAX request. The options object is used to identify
-     * additional parameters to be encoded into the request, and to identify the
-     * handlers for success and failure.
-     * <p>
-     * Option keys:
-     * <dl>
-     * <dt>parameters
-     * <dd>object with string keys and string values, defines additional query
-     * parameters
-     * <dt>failure
-     * <dd>A function invoked if the Ajax request fails; the function is passed
-     * the transport
-     * <dt>exception
-     * <dd>A function invoked if there's an exception processing the Ajax
-     * request, the function is passed the exception
-     * <dt>success
-     * <dd>A function invoked when the Ajax response is returned successfully.
-     * The function is passed the transport object.
-     * <dt>method
-     * <dd>The type of request, 'get' or 'post'. 'post' is the default.
-     * </dl>
-     *
-     * @param url
-     *            the URL for the request
-     * @param options
-     *            an optional object that provides additional options.
-     * @return not defined
-     *
-     */
-    function request(url, options) {
-
-        throw "not yet implemented";
-    }
-
-    return {
-        defaultFailure : defaultFailure,
-        defaultException : defaultException,
-        defaultSuccess : noop,
-        showExceptionDialog: showExceptionDialog,
-        request : request
-    };
+        return {
+            defaultFailure: defaultFailure,
+            defaultException: defaultException,
+            defaultSuccess: noop,
+            showExceptionDialog: showExceptionDialog,
+            request: request
+        };
+    });
 });
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a0fc1093/tapestry-core/src/main/resources/org/apache/tapestry5/t5-alerts.js
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/t5-alerts.js b/tapestry-core/src/main/resources/org/apache/tapestry5/t5-alerts.js
index 7397a68..40fbab7 100644
--- a/tapestry-core/src/main/resources/org/apache/tapestry5/t5-alerts.js
+++ b/tapestry-core/src/main/resources/org/apache/tapestry5/t5-alerts.js
@@ -1,117 +1,134 @@
-T5.extendInitializers(function() {
+/* Copyright 2011, 2012 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
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+define("core/compat/t5-alerts", ["core/compat/t5-dom"], function () {
+    T5.extendInitializers(function () {
+
+                var $ = T5.$;
+                var on = T5.dom.observe;
+                var find = T5.dom.find;
+                var DISMISS_ALERTS = "tapestry:dismiss-all";
+                var addAlertPublisher = T5.pubsub.createPublisher(T5.events.ADD_ALERT, document);
+
+                function construct(clientId, dismissText) {
+                    $(clientId).innerHTML = "<div class='t-alert-container'></div>" +
+                            "<div class='t-alert-controls'><a href='#'>" + dismissText + "</a></div>";
+
+                    var list = find(clientId, "div");
+                    var link = find(clientId, "a");
+
+                    T5.dom.publishEvent(link, "click", DISMISS_ALERTS);
+
+                    return list;
+                }
 
-        var $ = T5.$;
-        var on = T5.dom.observe;
-        var find = T5.dom.find;
-        var DISMISS_ALERTS = "tapestry:dismiss-all";
-        var addAlertPublisher = T5.pubsub.createPublisher(T5.events.ADD_ALERT, document);
+                /**
+                 * Specification with keys:
+                 * <dl>
+                 *   <dt>id</dt> <dd>id of empty client element</dd>
+                 *   <dt>dismissURL</dt> <dd>URL used to dismiss an alert</dd>
+                 * </dl>
+                 */
+                function alertManager(spec) {
 
-        function construct(clientId, dismissText) {
-            $(clientId).innerHTML = "<div class='t-alert-container'></div>" +
-                "<div class='t-alert-controls'><a href='#'>" + dismissText + "</a></div>";
+                    var visible = true;
+                    var constructed = false;
+                    var list = null;
 
-            var list = find(clientId, "div");
-            var link = find(clientId, "a");
+                    T5.sub(DISMISS_ALERTS, null, function () {
+                        if (constructed) {
+                            visible = false;
+                            T5.dom.hide(spec.id);
+                            visible = false;
 
-            T5.dom.publishEvent(link, "click", DISMISS_ALERTS);
+                            T5.dom.removeChildren(list);
 
-            return list;
-        }
+                            // Don't care about the response.
+                            Tapestry.ajaxRequest(spec.dismissURL);
+                        }
+                    });
 
-        /**
-         * Specification with keys:
-         * <dl>
-         *   <dt>id</dt> <dd>id of empty client element</dd>
-         *   <dt>dismissURL</dt> <dd>URL used to dismiss an alert</dd>
-         * </dl>
-         */
-        function alertManager(spec) {
+                    // For the moment, there's a bit of prototype linkage here.
 
-            var visible = true;
-            var constructed = false;
-            var list = null;
+                    T5.sub(T5.events.ADD_ALERT, null, function (alertSpec) {
+                        if (!constructed) {
+                            list = construct(spec.id, spec.dismissText);
+                            constructed = true;
+                        }
 
-            T5.sub(DISMISS_ALERTS, null, function() {
-                if (constructed) {
-                    visible = false;
-                    T5.dom.hide(spec.id);
-                    visible = false;
+                        if (!visible) {
+                            T5.dom.show(spec.id);
+                            visible = true;
+                        }
 
-                    T5.dom.removeChildren(list);
+                        // This part is Prototype specific, alas.
 
-                    // Don't care about the response.
-                    Tapestry.ajaxRequest(spec.dismissURL);
-                }
-            });
+                        var alertDiv = new Element("div", { "class": alertSpec['class'] }).update("<div class='t-dismiss' title='Dismiss'></div>" +
+                                "<div class='t-message-container'>" + alertSpec.message + "</div>");
 
-            // For the moment, there's a bit of prototype linkage here.
+                        list.insert({ bottom: alertDiv});
 
-            T5.sub(T5.events.ADD_ALERT, null, function(alertSpec) {
-                if (!constructed) {
-                    list = construct(spec.id, spec.dismissText);
-                    constructed = true;
-                }
+                        var dismiss = find(alertDiv, ".t-dismiss");
 
-                if (!visible) {
-                    T5.dom.show(spec.id);
-                    visible = true;
-                }
 
-                // This part is Prototype specific, alas.
+                        function removeAlert() {
+                            T5.dom.remove(alertDiv);
+                            if (list.innerHTML == '') {
+                                T5.dom.hide(spec.id);
+                                visible = false;
+                            }
+                        }
 
-                var alertDiv = new Element("div", { "class": alertSpec['class'] }).update("<div class='t-dismiss' title='Dismiss'></div>" +
-                    "<div class='t-message-container'>" + alertSpec.message + "</div>");
+                        // transient is a reserved word in JavaScript, which cause YUICompressor
+                        // to fail.
+                        if (alertSpec['transient']) {
+                            setTimeout(removeAlert, T5.alerts.TRANSIENT_DELAY);
+                        }
 
-                list.insert({ bottom: alertDiv});
+                        on(dismiss, "click", function (event) {
+                            event.stop();
 
-                var dismiss = find(alertDiv, ".t-dismiss");
+                            removeAlert();
 
+                            // TODO: Switch this to T5.ajax.sendRequest when implemented/available
 
-                function removeAlert() {
-                    T5.dom.remove(alertDiv);
-                    if (list.innerHTML == '') {
-                        T5.dom.hide(spec.id);
-                        visible = false;
-                    }
-                }
-
-                // transient is a reserved word in JavaScript, which cause YUICompressor
-                // to fail.
-                if (alertSpec['transient']) {
-                    setTimeout(removeAlert, T5.alerts.TRANSIENT_DELAY);
-                }
+                            // Send a request, we don't care about the response.
 
-                on(dismiss, "click", function(event) {
-                    event.stop();
+                            if (alertSpec.id) {
+                                Tapestry.ajaxRequest(spec.dismissURL,
+                                        { parameters: {
+                                            id: alertSpec.id
+                                        }});
+                            }
+                        });
 
-                    removeAlert();
-
-                    // TODO: Switch this to T5.ajax.sendRequest when implemented/available
-
-                    // Send a request, we don't care about the response.
-
-                    if (alertSpec.id) {
-                        Tapestry.ajaxRequest(spec.dismissURL,
-                            { parameters: {
-                                id : alertSpec.id
-                            }});
-                    }
-                });
-
-            });
-        }
+                    });
+                }
 
-        return {
-            alertManager : alertManager,
-            addAlert : addAlertPublisher
-        }
-    }
+                return {
+                    alertManager: alertManager,
+                    addAlert: addAlertPublisher
+                }
+            }
 
-)
+    )
     ;
 
-T5.define('alerts', {
-    /** Time, in ms, that a transient message is displayed before automatically dismissing. */
-    TRANSIENT_DELAY : 15000
-});
+    T5.define('alerts', {
+        /** Time, in ms, that a transient message is displayed before automatically dismissing. */
+        TRANSIENT_DELAY: 15000
+    });
 
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a0fc1093/tapestry-core/src/main/resources/org/apache/tapestry5/t5-console.js
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/t5-console.js b/tapestry-core/src/main/resources/org/apache/tapestry5/t5-console.js
index bef8077..6ee02b2 100644
--- a/tapestry-core/src/main/resources/org/apache/tapestry5/t5-console.js
+++ b/tapestry-core/src/main/resources/org/apache/tapestry5/t5-console.js
@@ -12,6 +12,8 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-T5.define("console", function () {
-    return T5.proxyFunctionsToModule("core/console", "debug", "info", "warn", "error");
-});
\ No newline at end of file
+define("core/compat/t5-console",
+        ["core/console", "core/compat/t5"],
+        function (console) {
+            T5.define("console", console);
+        });
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a0fc1093/tapestry-core/src/main/resources/org/apache/tapestry5/t5-core.js
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/t5-core.js b/tapestry-core/src/main/resources/org/apache/tapestry5/t5-core.js
index 2419e14..2bacfc4 100644
--- a/tapestry-core/src/main/resources/org/apache/tapestry5/t5-core.js
+++ b/tapestry-core/src/main/resources/org/apache/tapestry5/t5-core.js
@@ -1,4 +1,4 @@
-/* Copyright 2011 The Apache Software Foundation
+/* Copyright 2011, 2012 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.
@@ -13,91 +13,97 @@
  * limitations under the License.
  */
 
-/**
- * The master T5 namespace. A few critical functions are added directly to T5,
- * but mostly it is used as a containing namespace for namespaces defined by
- * other modules.
- *
- * @since 5.3
- */
-window.T5 = {
+define("core/compat/t5", ["_"], function (_) {
 
-    /** _ is _.noConflict(), in other words, all Underscore functions are not inside
-     * T5._, rather than simply _.
+    /**
+     * The master T5 namespace. A few critical functions are added directly to T5,
+     * but mostly it is used as a containing namespace for namespaces defined by
+     * other modules.
+     *
+     * @since 5.3
      */
-    _: _.noConflict()
-};
-
-/**
- * Extends an object using a source. In the simple case, the source object's
- * properties are overlaid on top of the destination object. In the typical
- * case, the source parameter is a function that returns the source object
- * ... this is to facilitate modularity and encapsulation.
- *
- * @param destination
- *            object to receive new or updated properties
- * @param source
- *            source object for properties, or function returning source
- *            object
- * @returns the destination object
- */
-T5.extend = function (destination, source) {
-    var _ = T5._;
+    window.T5 = {
 
-    if (_.isFunction(source)) {
-        source = source();
-    }
+        /** _ is _.noConflict(), in other words, all Underscore functions are not inside
+         * T5._, rather than simply _.
+         */
+        _: _.noConflict()
+    };
 
-    return _.extend(destination, source);
-};
+    /**
+     * Extends an object using a source. In the simple case, the source object's
+     * properties are overlaid on top of the destination object. In the typical
+     * case, the source parameter is a function that returns the source object
+     * ... this is to facilitate modularity and encapsulation.
+     *
+     * @param destination
+     *            object to receive new or updated properties
+     * @param source
+     *            source object for properties, or function returning source
+     *            object
+     * @returns the destination object
+     */
+    T5.extend = function (destination, source) {
+        var _ = T5._;
 
-/**
- * Defines a new namespace under the T5 object.
- *
- * @param name
- *            string name of the namespace
- * @param source
- *            source object for properties (or function returning source
- *            object)
- * @return the namespace object
- */
-T5.define = function (name, source) {
-    var namespace = {};
-    T5[name] = namespace;
-
-    return this.extend(namespace, source);
-};
-
-/**
- * Used when mapping a new-style module to an old-style namespace.
- * @param moduleName name of module to export from. Additional arguments are the function names
- * to proxy.
- * @param functionNames... names of functions to to proxy
- * @return  An object with the function names; each value is a function that uses require()
- * to obtain the function inside the module (asynchronously, at least the first time).
- */
-T5.proxyFunctionsToModule = function (moduleName) {
+        if (_.isFunction(source)) {
+            source = source();
+        }
+
+        return _.extend(destination, source);
+    };
+
+    /**
+     * Defines a new namespace under the T5 object.
+     *
+     * @param name
+     *            string name of the namespace
+     * @param source
+     *            source object for properties (or function returning source
+     *            object)
+     * @return the namespace object
+     */
+    T5.define = function (name, source) {
+        var namespace = {};
+        T5[name] = namespace;
+
+        return this.extend(namespace, source);
+    };
+
+    /**
+     * Used when mapping a new-style module to an old-style namespace.
+     * @param moduleName name of module to export from. Additional arguments are the function names
+     * to proxy.
+     * @param functionNames... names of functions to to proxy
+     * @return  An object with the function names; each value is a function that uses require()
+     * to obtain the function inside the module (asynchronously, at least the first time).
+     */
+    T5.proxyFunctionsToModule = function (moduleName) {
+
+        var slice = Array.prototype.slice;
+        var _ = T5._;
+
+        var functionNames = _.tail(arguments);
+        var deps = [moduleName];
+        var result = {}
 
-    var slice = Array.prototype.slice;
-    var _ = T5._;
+        // Force the module to be loaded early, so that there will not (usually) be a delay
+        // later.
+        require(deps, function () { });
 
-    var functionNames = _.tail(arguments);
-    var deps = [moduleName];
-    var result = {}
+        _.each(functionNames, function (name) {
+            result[name] = function () {
+                var capturedArguments = slice.call(arguments, 0);
 
-    // Force the module to be loaded early, so that there will not (usually) be a delay
-    // later.
-    require(deps, function () { });
+                require(deps, function (module) {
+                    module[name].apply(null, capturedArguments);
+                });
+            };
+        });
 
-    _.each(functionNames, function (name) {
-        result[name] = function () {
-            var capturedArguments = slice.call(arguments, 0);
+        return result;
+    };
 
-            require(deps, function (module) {
-                module[name].apply(null, capturedArguments);
-            });
-        };
-    });
+    return T5;
 
-    return result;
-};
+});

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a0fc1093/tapestry-core/src/main/resources/org/apache/tapestry5/t5-dom.js
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/t5-dom.js b/tapestry-core/src/main/resources/org/apache/tapestry5/t5-dom.js
index c759cab..f6d268f 100644
--- a/tapestry-core/src/main/resources/org/apache/tapestry5/t5-dom.js
+++ b/tapestry-core/src/main/resources/org/apache/tapestry5/t5-dom.js
@@ -1,4 +1,4 @@
-/* Copyright 2011 The Apache Software Foundation
+/* Copyright 2011, 2012 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.
@@ -13,145 +13,147 @@
  * limitations under the License.
  */
 
-T5.define("dom", function() {
+define("core/compat/t5-dom", ["core/compat/t5-spi", "core/compat/t5-events"], function () {
+    T5.define("dom", function () {
 
-    var _ = T5._;
+        var _ = T5._;
 
-    var removeEventHandlers;
+        var removeEventHandlers;
 
-    // Necessary to lazy-instantiate femoveEventHandlers publisher function,
-    // due to load order of these namespaces.
-    function doRemoveEventHandlers(element) {
-        if (!removeEventHandlers) {
-            removeEventHandlers = T5.pubsub.createPublisher(T5.events.REMOVE_EVENT_HANDLERS, document);
-        }
+        // Necessary to lazy-instantiate femoveEventHandlers publisher function,
+        // due to load order of these namespaces.
+        function doRemoveEventHandlers(element) {
+            if (!removeEventHandlers) {
+                removeEventHandlers = T5.pubsub.createPublisher(T5.events.REMOVE_EVENT_HANDLERS, document);
+            }
 
-        removeEventHandlers(element);
-    }
+            removeEventHandlers(element);
+        }
 
-    /**
-     * Locates an element. If element is a string, then
-     * document.getElementById() is used to resolve a client element id to a DOM
-     * element. If the id does not exist, then null will be returned.
-     * <p>
-     * If element is not a string, it is presumed to already by a DOM element,
-     * and is returned.
-     */
-    function locate(element) {
+        /**
+         * Locates an element. If element is a string, then
+         * document.getElementById() is used to resolve a client element id to a DOM
+         * element. If the id does not exist, then null will be returned.
+         * <p>
+         * If element is not a string, it is presumed to already by a DOM element,
+         * and is returned.
+         */
+        function locate(element) {
+
+            if (_.isString(element)) {
+                return document.getElementById(element);
+            }
 
-        if (_.isString(element)) {
-            return document.getElementById(element);
+            return element; // may be null, otherwise presumed to be a DOM node
         }
 
-        return element; // may be null, otherwise presumed to be a DOM node
-    }
+        /**
+         * Tree-walks the children of the element; for each dhild, ensure that all
+         * event handlers, listeners and PubSub publishers for the child are
+         * removed.
+         */
+        function purgeChildren(element) {
+            var children = element.childNodes;
 
-    /**
-     * Tree-walks the children of the element; for each dhild, ensure that all
-     * event handlers, listeners and PubSub publishers for the child are
-     * removed.
-     */
-    function purgeChildren(element) {
-        var children = element.childNodes;
-
-        if (children) {
-            var l = children.length, i, child;
+            if (children) {
+                var l = children.length, i, child;
 
-            for (i = 0; i < l; i++) {
-                var child = children[i];
+                for (i = 0; i < l; i++) {
+                    var child = children[i];
 
-                /* Just purge element nodes, not text, etc. */
-                if (child.nodeType == 1)
-                    purge(children[i]);
+                    /* Just purge element nodes, not text, etc. */
+                    if (child.nodeType == 1)
+                        purge(children[i]);
+                }
             }
         }
-    }
-
-    // Adapted from http://javascript.crockford.com/memory/leak.html
-    function purge(element) {
-        var attrs = element.attributes;
-        if (attrs) {
-            var i, name;
-            for (i = attrs.length - 1; i >= 0; i--) {
-                if (attrs[i]) {
-                    name = attrs[i].name;
-                    /* Looking for onclick, etc. */
-                    if (typeof element[name] == 'function') {
-                        element[name] = null;
+
+        // Adapted from http://javascript.crockford.com/memory/leak.html
+        function purge(element) {
+            var attrs = element.attributes;
+            if (attrs) {
+                var i, name;
+                for (i = attrs.length - 1; i >= 0; i--) {
+                    if (attrs[i]) {
+                        name = attrs[i].name;
+                        /* Looking for onclick, etc. */
+                        if (typeof element[name] == 'function') {
+                            element[name] = null;
+                        }
                     }
                 }
             }
-        }
 
-        purgeChildren(element);
+            purgeChildren(element);
 
-        if (element.t5pubsub) {
-            _.defer(function() {
-                T5.pubsub.cleanupRemovedElement(element)
-            });
+            if (element.t5pubsub) {
+                _.defer(function () {
+                    T5.pubsub.cleanupRemovedElement(element)
+                });
+            }
+
+            doRemoveEventHandlers(element);
         }
 
-        doRemoveEventHandlers(element);
-    }
+        /**
+         * Removes an element and all of its direct and indirect children. The
+         * element is first purged, to ensure that Internet Explorer doesn't leak
+         * memory if event handlers associated with the element (or its children)
+         * have references back to the element. This also removes all Prototype
+         * event handlers, and uses T5.pubsub.cleanupRemovedElement() to delete and
+         * publishers or subscribers for any removed elements.
+         *
+         */
+        function remove(element) {
+            purge(element);
+
+            // Remove the element, and all children, in one go.
+            Element.remove(element);
+        }
 
-    /**
-     * Removes an element and all of its direct and indirect children. The
-     * element is first purged, to ensure that Internet Explorer doesn't leak
-     * memory if event handlers associated with the element (or its children)
-     * have references back to the element. This also removes all Prototype
-     * event handlers, and uses T5.pubsub.cleanupRemovedElement() to delete and
-     * publishers or subscribers for any removed elements.
-     *
-     */
-    function remove(element) {
-        purge(element);
+        /**
+         * Removes all children form the element, properly purging child elements
+         * of any listeners, etc.
+         * @param element to purge
+         */
+        function removeChildren(element) {
+            purgeChildren(element);
+            element.innerHTML = '';
+        }
 
-        // Remove the element, and all children, in one go.
-        Element.remove(element);
-    }
+        /**
+         * Observes an event on an element; when the event is triggered, the event
+         * is published as a message.  Listeners to the topic may cancel the event.
+         * @param element element or element id
+         * @param eventName name of event to observe
+         * @param topic topic name used to publish the event
+         */
+        function publishEvent(element, eventName, topic) {
+            var publisher = T5.pubsub.createPublisher(topic, element);
+
+            T5.dom.observe(element, eventName, function (event) {
+                publisher(event);
+            });
+        }
 
-    /**
-     * Removes all children form the element, properly purging child elements
-     * of any listeners, etc.
-     * @param element to purge
-     */
-    function removeChildren(element) {
-        purgeChildren(element);
-        element.innerHTML = '';
-    }
+        return {
+            remove: remove,
+            removeChildren: removeChildren,
+            purgeChildren: purgeChildren,
+            locate: locate,
+            observe: T5.spi.observe,
+            find: T5.spi.find,
+            hide: T5.spi.hide,
+            show: T5.spi.show,
+            appendMarkup: T5.spi.appendMarkup,
+            publishEvent: publishEvent
+        };
+    });
 
     /**
-     * Observes an event on an element; when the event is triggered, the event
-     * is published as a message.  Listeners to the topic may cancel the event.
-     * @param element element or element id
-     * @param eventName name of event to observe
-     * @param topic topic name used to publish the event
+     * Create a T5.$() synonym for T5.dom.locate().
      */
-    function publishEvent(element, eventName, topic) {
-        var publisher = T5.pubsub.createPublisher(topic, element);
-
-        T5.dom.observe(element, eventName, function(event) {
-            publisher(event);
-        });
-    }
-
-    return {
-        remove : remove,
-        removeChildren : removeChildren,
-        purgeChildren : purgeChildren,
-        locate : locate,
-        observe : T5.spi.observe,
-        find : T5.spi.find,
-        hide : T5.spi.hide,
-        show : T5.spi.show,
-        appendMarkup : T5.spi.appendMarkup,
-        publishEvent : publishEvent
-    };
-});
-
-/**
- * Create a T5.$() synonym for T5.dom.locate().
- */
-T5.extend(T5, {
-    $ : T5.dom.locate
+    T5.extend(T5, {
+        $: T5.dom.locate
+    });
 });
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a0fc1093/tapestry-core/src/main/resources/org/apache/tapestry5/t5-events.js
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/t5-events.js b/tapestry-core/src/main/resources/org/apache/tapestry5/t5-events.js
index 3312e3f..ec0c38c 100644
--- a/tapestry-core/src/main/resources/org/apache/tapestry5/t5-events.js
+++ b/tapestry-core/src/main/resources/org/apache/tapestry5/t5-events.js
@@ -1,4 +1,4 @@
-/* Copyright 2011 The Apache Software Foundation
+/* Copyright 2011, 2012 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.
@@ -16,28 +16,30 @@
 /**
  * Defines the names of events used with the publish/subscribe framework.
  */
-T5.define("events", {
+define("core/compat/t5-events", ["core/compat/t5"], function () {
+    T5.define("events", {
 
-    /**
-     * Published as an element is being removed from the DOM, to allow framework-specific
-     * approaches to removing any event listeners for the element. This is published on the document object,
-     * and the message is the DOM element for which event handlers should be removed.
-     */
-    REMOVE_EVENT_HANDLERS : "tapestry:remove-event-handlers",
+        /**
+         * Published as an element is being removed from the DOM, to allow framework-specific
+         * approaches to removing any event listeners for the element. This is published on the document object,
+         * and the message is the DOM element for which event handlers should be removed.
+         */
+        REMOVE_EVENT_HANDLERS: "tapestry:remove-event-handlers",
 
-    /** Event used to display a new alert to the user. The message is the alert specification, with keys:
-     * <dl>
-     *  <dt>id</dt>
-     *  <dd>unique numeric id for the alert, if the alert is persistent on the server (omitted for non-persistent
-     *  alerts)</dd>
-     *  <dt>transient</dt>
-     *  <dd>If true (may be omitted), then the alert will automatically dismiss itself after a period of time.</dd>
-     *  <dt>class</dt>
-     *  <dd>The CSS class, which should be 't-info', 't-warn' or 't-error'.</dd>
-     *  <dt>message</dt>
-     *  <dd>The alert message content.</dd>
-     *  </dl>
-     */
-    ADD_ALERT : "tapestry:add-alert"
+        /** Event used to display a new alert to the user. The message is the alert specification, with keys:
+         * <dl>
+         *  <dt>id</dt>
+         *  <dd>unique numeric id for the alert, if the alert is persistent on the server (omitted for non-persistent
+         *  alerts)</dd>
+         *  <dt>transient</dt>
+         *  <dd>If true (may be omitted), then the alert will automatically dismiss itself after a period of time.</dd>
+         *  <dt>class</dt>
+         *  <dd>The CSS class, which should be 't-info', 't-warn' or 't-error'.</dd>
+         *  <dt>message</dt>
+         *  <dd>The alert message content.</dd>
+         *  </dl>
+         */
+        ADD_ALERT: "tapestry:add-alert"
 
+    });
 });
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a0fc1093/tapestry-core/src/main/resources/org/apache/tapestry5/t5-formfragment.js
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/t5-formfragment.js b/tapestry-core/src/main/resources/org/apache/tapestry5/t5-formfragment.js
index 09f926f..84ff768 100644
--- a/tapestry-core/src/main/resources/org/apache/tapestry5/t5-formfragment.js
+++ b/tapestry-core/src/main/resources/org/apache/tapestry5/t5-formfragment.js
@@ -1,84 +1,101 @@
-T5.extendInitializers(function() {
-
-    function init(spec) {
-
-        var element = $(spec.element);
-
-        var hidden = $(spec.element + "-hidden");
-        var form = $(hidden.form);
+/* Copyright 2011, 2012 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
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+define("core/compat/t5-formfragment", ["core/compat/t5-init"], function () {
+    T5.extendInitializers(function () {
+
+        function init(spec) {
+
+            var element = $(spec.element);
+
+            var hidden = $(spec.element + "-hidden");
+            var form = $(hidden.form);
+
+            var opts = (spec.bound && { bound: spec.bound }) || {};
+            if (!spec.alwaysSubmit) {
+                hidden.disabled = !element.isDeepVisible(opts);
+            }
 
-        var opts = (spec.bound && { bound: spec.bound }) || {};
-        if (! spec.alwaysSubmit) {
-            hidden.disabled = !  element.isDeepVisible(opts);
-        }
+            function updateUI(makeVisible) {
 
-        function updateUI(makeVisible) {
+                if (!spec.alwaysSubmit) {
+                    hidden.disabled = !(makeVisible && element.parentNode.isDeepVisible(opts));
+                }
 
-            if (! spec.alwaysSubmit) {
-                hidden.disabled = ! (makeVisible && element.parentNode.isDeepVisible(opts));
+                var effect = makeVisible ? Tapestry.ElementEffect[spec.show]
+                        || Tapestry.ElementEffect.slidedown
+                        : Tapestry.ElementEffect[spec.hide]
+                        || Tapestry.ElementEffect.slideup;
+                return effect(element);
             }
 
-            var effect = makeVisible ? Tapestry.ElementEffect[spec.show]
-                || Tapestry.ElementEffect.slidedown
-                : Tapestry.ElementEffect[spec.hide]
-                || Tapestry.ElementEffect.slideup;
-            return effect(element);
-        }
-
-        element.observe(Tapestry.CHANGE_VISIBILITY_EVENT, function(event) {
-            // Since events propagate up, you have to call event.stop()
-            // here to prevent hiding/revealing any container FormFragment elements.
-            event.stop();
+            element.observe(Tapestry.CHANGE_VISIBILITY_EVENT, function (event) {
+                // Since events propagate up, you have to call event.stop()
+                // here to prevent hiding/revealing any container FormFragment elements.
+                event.stop();
 
-            var makeVisible = event.memo.visible;
+                var makeVisible = event.memo.visible;
 
-            if (makeVisible == element.visible())
-                return;
+                if (makeVisible == element.visible())
+                    return;
 
-            updateUI(makeVisible);
-        });
+                updateUI(makeVisible);
+            });
 
-        element.observe(Tapestry.HIDE_AND_REMOVE_EVENT,
-            function(event) {
-                event.stop();
-                var effect = updateUI(false);
+            element.observe(Tapestry.HIDE_AND_REMOVE_EVENT,
+                    function (event) {
+                        event.stop();
+                        var effect = updateUI(false);
 
-                effect.options.afterFinish = function() {
-                    Tapestry.remove(element);
-                };
-            });
-    }
-
-    /**
-     * Links a FormFragment to a trigger (a radio or a checkbox), such
-     * that changing the trigger will hide or show the FormFragment.
-     * Care should be taken to render the page with the checkbox and the
-     * FormFragment's visibility in agreement.
-     */
-    function linker(spec) {
-        var trigger = $(spec.triggerId);
-
-        function update() {
-            var checked = trigger.checked;
-            var makeVisible = checked == !spec.invert;
-
-            $(spec.fragmentId).fire(Tapestry.CHANGE_VISIBILITY_EVENT, {
-                visible : makeVisible
-            }, true);
+                        effect.options.afterFinish = function () {
+                            Tapestry.remove(element);
+                        };
+                    });
         }
 
-        // Let the event bubble up to the form level.
-        if (trigger.type == "radio") {
-            $(trigger.form).observe("click", update);
-            return;
-        }
+        /**
+         * Links a FormFragment to a trigger (a radio or a checkbox), such
+         * that changing the trigger will hide or show the FormFragment.
+         * Care should be taken to render the page with the checkbox and the
+         * FormFragment's visibility in agreement.
+         */
+        function linker(spec) {
+            var trigger = $(spec.triggerId);
+
+            function update() {
+                var checked = trigger.checked;
+                var makeVisible = checked == !spec.invert;
+
+                $(spec.fragmentId).fire(Tapestry.CHANGE_VISIBILITY_EVENT, {
+                    visible: makeVisible
+                }, true);
+            }
 
-        // Normal trigger is a checkbox; listen just to it.
-        trigger.observe("click", update);
-    }
+            // Let the event bubble up to the form level.
+            if (trigger.type == "radio") {
+                $(trigger.form).observe("click", update);
+                return;
+            }
+
+            // Normal trigger is a checkbox; listen just to it.
+            trigger.observe("click", update);
+        }
 
-    return {
-        formFragment : init,
-        linkTriggerToFormFragment : linker
-    };
-});
+        return {
+            formFragment: init,
+            linkTriggerToFormFragment: linker
+        };
+    });
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a0fc1093/tapestry-core/src/main/resources/org/apache/tapestry5/t5-init.js
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/t5-init.js b/tapestry-core/src/main/resources/org/apache/tapestry5/t5-init.js
index 8686771..76e7839 100644
--- a/tapestry-core/src/main/resources/org/apache/tapestry5/t5-init.js
+++ b/tapestry-core/src/main/resources/org/apache/tapestry5/t5-init.js
@@ -1,4 +1,4 @@
-/* Copyright 2011 The Apache Software Foundation
+/* Copyright 2011, 2012 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.
@@ -14,23 +14,26 @@
  */
 
 /** Extends T5 with new functions related to page initialization. */
-T5.extend(T5, function() {
 
-	return {
-		/**
-		 * The T5.Initializer namespace, which contains functions used to
-		 * perform page load initializations.
-		 */
-		initializers : {},
+define("core/compat/t5-init", ["core/compat/t5"], function () {
+    T5.extend(T5, function () {
 
-		/**
-		 * A convenience method for extending the T5.Initializer namespace.
-		 * 
-		 * @param source
-		 *            object or function used to extend T5.initializers
-		 */
-		extendInitializers : function(source) {
-			T5.extend(T5.initializers, source);
-		}
-	};
+        return {
+            /**
+             * The T5.Initializer namespace, which contains functions used to
+             * perform page load initializations.
+             */
+            initializers: {},
+
+            /**
+             * A convenience method for extending the T5.Initializer namespace.
+             *
+             * @param source
+             *            object or function used to extend T5.initializers
+             */
+            extendInitializers: function (source) {
+                T5.extend(T5.initializers, source);
+            }
+        };
+    });
 });
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a0fc1093/tapestry-core/src/main/resources/org/apache/tapestry5/t5-prototype.js
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/t5-prototype.js b/tapestry-core/src/main/resources/org/apache/tapestry5/t5-prototype.js
index dd51b02..992b30f 100644
--- a/tapestry-core/src/main/resources/org/apache/tapestry5/t5-prototype.js
+++ b/tapestry-core/src/main/resources/org/apache/tapestry5/t5-prototype.js
@@ -1,4 +1,4 @@
-/* Copyright 2011 The Apache Software Foundation
+/* Copyright 2011, 2012 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.
@@ -18,42 +18,44 @@
  * Prototype JavaScript library. May also make modifications to Prototype to
  * work with Tapestry.
  */
-T5.extend(T5.spi, function() {
+define("core/compat/t5-prototype", ["core/compat/t5-spi"], function () {
+    T5.extend(T5.spi, function () {
 
-    function observe(element, eventName, listener) {
+        function observe(element, eventName, listener) {
 
-        var handler = $(element).on(eventName, listener);
+            var handler = $(element).on(eventName, listener);
 
-        element = null;
-        eventName = null;
-        listener = null;
+            element = null;
+            eventName = null;
+            listener = null;
 
-        return function() {
-            handler.stop();
-        };
-    }
+            return function () {
+                handler.stop();
+            };
+        }
 
-    document.observe("dom:loaded", function() {
-        T5.sub(T5.events.REMOVE_EVENT_HANDLERS, null, function(element) {
-                Event.stopObserving(element);
-            }
-        );
-    });
+        document.observe("dom:loaded", function () {
+            T5.sub(T5.events.REMOVE_EVENT_HANDLERS, null, function (element) {
+                        Event.stopObserving(element);
+                    }
+            );
+        });
 
-    function appendMarkup(element, markup) {
-        var element = $(element);
+        function appendMarkup(element, markup) {
+            var element = $(element);
 
-        element.insert({ bottom: markup });
+            element.insert({ bottom: markup });
 
-        return element;
-    }
+            return element;
+        }
 
-    return {
-        observe : observe,
-        find : Element.down,
-        show : Element.show,
-        hide : Element.hide,
-        appendMarkup : appendMarkup
-    };
-});
+        return {
+            observe: observe,
+            find: Element.down,
+            show: Element.show,
+            hide: Element.hide,
+            appendMarkup: appendMarkup
+        };
+    });
 
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a0fc1093/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 e4716bb..836a97f 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
@@ -1,248 +1,265 @@
-T5.define("pubsub", function() {
-
-    var _ = T5._;
-
-    // Element keys: topic, element, listenerfn
-    // May be multiple elements with some topic/element pair
-    // element property may be undefined
-    var subscribers = [];
-
-    // Element keys: topic, element, publisherfn
-    var publishers = [];
+/* Copyright 2011, 2012 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
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 
-    // Necessary since T5.dom depends on T5.pubsub
-    function $(element) {
-        return T5.$(element);
-    }
+define("core/compat/t5-pubsub", ["core/compat/t5"], function () {
+    T5.define("pubsub", function () {
 
-    function purgePublisherCache(topic) {
-        _.each(publishers, function(publisher) {
-            if (publisher.topic === topic) {
-                publisher.listeners = undefined;
-            }
-        });
-    }
+        var _ = T5._;
 
-    function findListeners(topic, element) {
-        var gross = _.select(subscribers, function(subscriber) {
-            return subscriber.topic === topic;
-        });
+        // Element keys: topic, element, listenerfn
+        // May be multiple elements with some topic/element pair
+        // element property may be undefined
+        var subscribers = [];
 
-        var primary = _.select(gross, function(subscriber) {
-            return subscriber.element === element;
-        });
+        // Element keys: topic, element, publisherfn
+        var publishers = [];
 
-        var secondary = _.select(gross, function(subscriber) {
-            // Match where the element is null or undefined
-            return !subscriber.element;
-        });
+        // Necessary since T5.dom depends on T5.pubsub
+        function $(element) {
+            return T5.$(element);
+        }
 
-        // Return the listenerfn property from each match.
-        return _(primary).chain().union(secondary).pluck("listenerfn").value();
-    }
+        function purgePublisherCache(topic) {
+            _.each(publishers, function (publisher) {
+                if (publisher.topic === topic) {
+                    publisher.listeners = undefined;
+                }
+            });
+        }
 
-    /**
-     * Subscribes a listener function to the selector. The listener function
-     * will be invoked when a message for the given topic is published. If an
-     * element is specified, then the listener will only be invoked when the
-     * subscribed element matches the published element.
-     *
-     * @param topic
-     *            a topic name, which must not be blank
-     * @param element
-     *            a DOM element, which may be null to subscribe to all messages
-     *            for the topic. If a string, then T5.$() is used to locate the
-     *            DOM element with the matching client id.
-     * @param listenerfn
-     *            function invoked when a message for the topic is published.
-     *            The function is invoked only if the supplied selector element
-     *            is undefined OR exactly matches the source element node. The
-     *            return value of the listenerfn will be accumulated in an array
-     *            and returned to the publisher.
-     *
-     *            The listener function is passed a message object as the first parameter; this is provided
-     *            on each call to the topic's publish function. The second parameter is an object with two
-     *            properties:  An element property to identify the source of the message, and a cancel() function property
-     *            that prevents further listeners from being invoked.
-     * @return a function of no arguments used to unsubscribe the listener
-     */
-    function subscribe(topic, element, listenerfn) {
+        function findListeners(topic, element) {
+            var gross = _.select(subscribers, function (subscriber) {
+                return subscriber.topic === topic;
+            });
 
-        var subscriber = {
-            topic : topic,
-            element : $(element),
-            listenerfn : listenerfn
-        };
+            var primary = _.select(gross, function (subscriber) {
+                return subscriber.element === element;
+            });
 
-        subscribers.push(subscriber);
-        purgePublisherCache(subscriber.topic);
+            var secondary = _.select(gross, function (subscriber) {
+                // Match where the element is null or undefined
+                return !subscriber.element;
+            });
 
-        // To prevent memory leaks via closure:
-
-        topic = null;
-        element = null;
-        listenerfn = null;
+            // Return the listenerfn property from each match.
+            return _(primary).chain().union(secondary).pluck("listenerfn").value();
+        }
 
-        // Return a function to unsubscribe
-        return function() {
-            subscribers = _.without(subscribers, subscriber);
+        /**
+         * Subscribes a listener function to the selector. The listener function
+         * will be invoked when a message for the given topic is published. If an
+         * element is specified, then the listener will only be invoked when the
+         * subscribed element matches the published element.
+         *
+         * @param topic
+         *            a topic name, which must not be blank
+         * @param element
+         *            a DOM element, which may be null to subscribe to all messages
+         *            for the topic. If a string, then T5.$() is used to locate the
+         *            DOM element with the matching client id.
+         * @param listenerfn
+         *            function invoked when a message for the topic is published.
+         *            The function is invoked only if the supplied selector element
+         *            is undefined OR exactly matches the source element node. The
+         *            return value of the listenerfn will be accumulated in an array
+         *            and returned to the publisher.
+         *
+         *            The listener function is passed a message object as the first parameter; this is provided
+         *            on each call to the topic's publish function. The second parameter is an object with two
+         *            properties:  An element property to identify the source of the message, and a cancel() function property
+         *            that prevents further listeners from being invoked.
+         * @return a function of no arguments used to unsubscribe the listener
+         */
+        function subscribe(topic, element, listenerfn) {
+
+            var subscriber = {
+                topic: topic,
+                element: $(element),
+                listenerfn: listenerfn
+            };
+
+            subscribers.push(subscriber);
             purgePublisherCache(subscriber.topic);
-        }
-    }
 
-    /**
-     * Creates a publish function for the indicated topic name and DOM element. For global
-     * events, the convention is to use the document object.
-     *
-     * <p>
-     * The returned function is used to publish a message. Messages are
-     * published synchronously. The publish function will invoke listener
-     * functions for matching subscribers (subscribers to the same topic). Exact
-     * subscribers (matching the specific element) are invoked first, then
-     * general subscribers (not matching any specific element). The return value
-     * for the publish function is an array of all the return values from all
-     * invoked listener functions.
-     *
-     * <p>
-     * Listener functions are passed the message object and a second (optional) object.
-     * The second object contains two keys:  The first, "element", identifies the element for which the publisher was created, i.e.,
-     * the source of the message. The second, "cancel", is a function used to prevent further listeners
-     * from being invoked.
-     *
-     * <p>
-     * There is not currently a way to explicitly remove a publisher; however,
-     * when the DOM element is removed properly, all publishers and subscribers
-     * for the specific element will be removed as well.
-     *
-     * <p>
-     * Publish functions are cached, repeated calls with the same topic and
-     * element return the same publish function.
-     *
-     * @param topic
-     *            used to select listeners
-     * @param element
-     *            the DOM element used as the source of the published message
-     *            (also used to select listeners). Passed through T5.$(), the
-     *            result must not be null.   The element will be passed to listener function as
-     *            the second parameter.
-     * @return publisher function used to publish a message
-     */
-    function createPublisher(topic, element) {
+            // To prevent memory leaks via closure:
 
-        element = $(element);
+            topic = null;
+            element = null;
+            listenerfn = null;
 
-        if (element == null) {
-            throw "Element may not be null when creating a publisher.";
+            // Return a function to unsubscribe
+            return function () {
+                subscribers = _.without(subscribers, subscriber);
+                purgePublisherCache(subscriber.topic);
+            }
         }
 
-        var existing = _.detect(publishers, function(publisher) {
-            return publisher.topic === topic && publisher.element === element;
-        });
-
-        if (existing) {
-            return existing.publisherfn;
-        }
+        /**
+         * Creates a publish function for the indicated topic name and DOM element. For global
+         * events, the convention is to use the document object.
+         *
+         * <p>
+         * The returned function is used to publish a message. Messages are
+         * published synchronously. The publish function will invoke listener
+         * functions for matching subscribers (subscribers to the same topic). Exact
+         * subscribers (matching the specific element) are invoked first, then
+         * general subscribers (not matching any specific element). The return value
+         * for the publish function is an array of all the return values from all
+         * invoked listener functions.
+         *
+         * <p>
+         * Listener functions are passed the message object and a second (optional) object.
+         * The second object contains two keys:  The first, "element", identifies the element for which the publisher was created, i.e.,
+         * the source of the message. The second, "cancel", is a function used to prevent further listeners
+         * from being invoked.
+         *
+         * <p>
+         * There is not currently a way to explicitly remove a publisher; however,
+         * when the DOM element is removed properly, all publishers and subscribers
+         * for the specific element will be removed as well.
+         *
+         * <p>
+         * Publish functions are cached, repeated calls with the same topic and
+         * element return the same publish function.
+         *
+         * @param topic
+         *            used to select listeners
+         * @param element
+         *            the DOM element used as the source of the published message
+         *            (also used to select listeners). Passed through T5.$(), the
+         *            result must not be null.   The element will be passed to listener function as
+         *            the second parameter.
+         * @return publisher function used to publish a message
+         */
+        function createPublisher(topic, element) {
+
+            element = $(element);
+
+            if (element == null) {
+                throw "Element may not be null when creating a publisher.";
+            }
 
-        var publisher = {
-            topic : topic,
-            element : element,
-            publisherfn : function(message) {
+            var existing = _.detect(publishers, function (publisher) {
+                return publisher.topic === topic && publisher.element === element;
+            });
 
-                if (publisher.listeners == undefined) {
-                    publisher.listeners = findListeners(publisher.topic,
-                        publisher.element);
-                }
+            if (existing) {
+                return existing.publisherfn;
+            }
 
-                var canceled = false;
+            var publisher = {
+                topic: topic,
+                element: element,
+                publisherfn: function (message) {
 
-                var meta = {
-                    element : publisher.element,
-                    cancel : function() {
-                        canceled = true;
+                    if (publisher.listeners == undefined) {
+                        publisher.listeners = findListeners(publisher.topic,
+                                publisher.element);
                     }
-                };
 
-                var result = [];
+                    var canceled = false;
+
+                    var meta = {
+                        element: publisher.element,
+                        cancel: function () {
+                            canceled = true;
+                        }
+                    };
+
+                    var result = [];
 
-                for (var i = 0; i < publisher.listeners.length; i++) {
+                    for (var i = 0; i < publisher.listeners.length; i++) {
 
-                    var listenerfn = publisher.listeners[i];
+                        var listenerfn = publisher.listeners[i];
 
-                    result.push(listenerfn(message, meta));
+                        result.push(listenerfn(message, meta));
 
-                    if (canceled) {
-                        break;
+                        if (canceled) {
+                            break;
+                        }
                     }
+
+                    return result;
                 }
+            };
 
-                return result;
-            }
-        };
+            publishers.push(publisher);
 
-        publishers.push(publisher);
+            // If only there was an event or something that would inform us when the
+            // element was removed. Certainly, IE doesn't support that! Have to rely
+            // on T5.dom.remove() to inform us.
 
-        // If only there was an event or something that would inform us when the
-        // element was removed. Certainly, IE doesn't support that! Have to rely
-        // on T5.dom.remove() to inform us.
+            // Mark the element to indicate it requires cleanup once removed from
+            // the DOM.
 
-        // Mark the element to indicate it requires cleanup once removed from
-        // the DOM.
+            element.t5pubsub = true;
 
-        element.t5pubsub = true;
+            // Don't want to hold a reference via closure:
 
-        // Don't want to hold a reference via closure:
+            topic = null;
+            element = null;
 
-        topic = null;
-        element = null;
+            return publisher.publisherfn;
+        }
 
-        return publisher.publisherfn;
-    }
+        /**
+         * Creates a publisher and immediately publishes the message, return the
+         * array of results.
+         */
+        function publish(topic, element, message) {
+            return createPublisher(topic, element)(message);
+        }
 
-    /**
-     * Creates a publisher and immediately publishes the message, return the
-     * array of results.
-     */
-    function publish(topic, element, message) {
-        return createPublisher(topic, element)(message);
-    }
+        /**
+         * Invoked whenever an element is about to be removed from the DOM to remove
+         * any publishers or subscribers for the element.
+         */
+        function cleanup(element) {
+            subscribers = _.reject(subscribers, function (subscriber) {
+                return subscriber.element === element
+            });
 
-    /**
-     * Invoked whenever an element is about to be removed from the DOM to remove
-     * any publishers or subscribers for the element.
-     */
-    function cleanup(element) {
-        subscribers = _.reject(subscribers, function(subscriber) {
-            return subscriber.element === element
-        });
+            // A little evil to modify the publisher object at the same time it is
+            // being removed.
 
-        // A little evil to modify the publisher object at the same time it is
-        // being removed.
+            publishers = _.reject(publishers, function (publisher) {
+                var match = publisher.element === element;
 
-        publishers = _.reject(publishers, function(publisher) {
-            var match = publisher.element === element;
+                if (match) {
+                    publisher.listeners = undefined;
+                    publisher.element = undefined;
+                }
 
-            if (match) {
-                publisher.listeners = undefined;
-                publisher.element = undefined;
-            }
+                return match;
+            });
+        }
 
-            return match;
-        });
-    }
-
-    return {
-        createPublisher : createPublisher,
-        subscribe : subscribe,
-        publish : publish,
-        cleanupRemovedElement : cleanup
-    };
-});
-
-/**
- * Create aliases on T5 directly: pub -&gt; T5.pubsub.publish and sub -&gt;
- * T5.pubsub.subscribe.
- */
-T5.extend(T5, {
-    pub : T5.pubsub.publish,
-    sub : T5.pubsub.subscribe
+        return {
+            createPublisher: createPublisher,
+            subscribe: subscribe,
+            publish: publish,
+            cleanupRemovedElement: cleanup
+        };
+    });
+
+    /**
+     * Create aliases on T5 directly: pub -&gt; T5.pubsub.publish and sub -&gt;
+     * T5.pubsub.subscribe.
+     */
+    T5.extend(T5, {
+        pub: T5.pubsub.publish,
+        sub: T5.pubsub.subscribe
+    });
 });
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a0fc1093/tapestry-core/src/main/resources/org/apache/tapestry5/t5-spi.js
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/t5-spi.js b/tapestry-core/src/main/resources/org/apache/tapestry5/t5-spi.js
index 58688d8..e6a245e 100644
--- a/tapestry-core/src/main/resources/org/apache/tapestry5/t5-spi.js
+++ b/tapestry-core/src/main/resources/org/apache/tapestry5/t5-spi.js
@@ -1,4 +1,4 @@
-/* Copyright 2011 The Apache Software Foundation
+/* Copyright 2011, 2012 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.
@@ -24,56 +24,58 @@
  * functions; a framework layer may leave such a function alone or re-implement
  * it.
  */
-T5.define("spi", {
+define("core/compat/t5-spi", ["core/compat/t5"], function () {
+    T5.define("spi", {
 
-    /**
-     * Observes a DOM event.
-     *
-     *  @param element DOM element or element id
-     *  @param event name of event to observe
-     *  @param listener function to be invoked; the function is passed the DOM event object
-     *  @return cancel function to stop observing the event with the listener
-     */
-    observe : undefined,
+        /**
+         * Observes a DOM event.
+         *
+         *  @param element DOM element or element id
+         *  @param event name of event to observe
+         *  @param listener function to be invoked; the function is passed the DOM event object
+         *  @return cancel function to stop observing the event with the listener
+         */
+        observe: undefined,
 
-    /**
-     * Find the first child element matching a CSS selector.
-     *
-     * @param element DOM element or element id
-     * @param selector CSS selector to locate
-     * @return the element, or undefined if not found
-     */
-    find : undefined,
+        /**
+         * Find the first child element matching a CSS selector.
+         *
+         * @param element DOM element or element id
+         * @param selector CSS selector to locate
+         * @return the element, or undefined if not found
+         */
+        find: undefined,
 
-    /** Hides an element making it invisible.
-     * @param element DOM element or element id
-     */
-    hide : undefined,
+        /** Hides an element making it invisible.
+         * @param element DOM element or element id
+         */
+        hide: undefined,
 
-    /** Reveals an element, making it visible again.
-     *
-     * @param element DOM element or element id
-     */
-    show : undefined,
+        /** Reveals an element, making it visible again.
+         *
+         * @param element DOM element or element id
+         */
+        show: undefined,
 
-    /**
-     * Appends new markup to an existing element's body.
-     *
-     * @param element DOM element or element id
-     * @param markup new content as markup string
-     * @return element
-     */
-    appendMarkup: undefined,
+        /**
+         * Appends new markup to an existing element's body.
+         *
+         * @param element DOM element or element id
+         * @param markup new content as markup string
+         * @return element
+         */
+        appendMarkup: undefined,
 
-    /**
-     * Performs an ajax request, as per T5.ajax.request(). Supplied by the SPI
-     * implementation. The options parameter is not yet fully defined in Tapestry 5.3
-     * (this SPI function is not yet used anywhere).
-     *
-     * @param url
-     *            URL for Ajax request
-     * @param options
-     *            additional options defined by T5.ajax.request().
-     */
-    ajaxRequest : undefined
+        /**
+         * Performs an ajax request, as per T5.ajax.request(). Supplied by the SPI
+         * implementation. The options parameter is not yet fully defined in Tapestry 5.3
+         * (this SPI function is not yet used anywhere).
+         *
+         * @param url
+         *            URL for Ajax request
+         * @param options
+         *            additional options defined by T5.ajax.request().
+         */
+        ajaxRequest: undefined
+    });
 });
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a0fc1093/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-console.js
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-console.js b/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-console.js
index a363339..88e45cb 100644
--- a/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-console.js
+++ b/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-console.js
@@ -1,4 +1,4 @@
-// Copyright 2009, 2010, 2011 The Apache Software Foundation
+// Copyright 2009, 2010, 2011, 2012 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.
@@ -15,13 +15,15 @@
 /**
  * @deprecated in 5.3, use equivalent T5.console functions instead.
  */
-Tapestry.Logging = {
+define("core/compat/tapestry-console", ["core/compat/tapestry"], function () {
+    Tapestry.Logging = {
 
-  debug : T5.console.debug,
+        debug: T5.console.debug,
 
-  info : T5.console.info,
+        info: T5.console.info,
 
-  warn : T5.console.warn,
+        warn: T5.console.warn,
 
-  error: T5.console.error
-};
\ No newline at end of file
+        error: T5.console.error
+    };
+});
\ No newline at end of file