I think
http://trac.mochikit.com/ticket/192
may have gotten lost inside of Trac spam, and I can't update my patch,
since it's labeling it as spam, so I'll post the update here instead
(ironically my last patch is broken after __connect__ was committed at
my own request!).
Anyway, my patch is making my sites load faster, so here it is:
Index: Signal.js
===================================================================
--- Signal.js   (revision 1191)
+++ Signal.js   (working copy)
@@ -547,6 +547,33 @@
         }
     },

+    _browserAlreadyHasDOMContentLoaded: function () {
+        return (document.addEventListener);
+    },
+
+    _domContentLoadListener: function (src, sig, func, obj) {
+        var E = MochiKit.Signal.Event;
+       return function(nativeEvent) {
+           var s=nativeEvent.srcElement;
+           if (s.readyState != "complete" ) return;
+           try {
+               if (s.id=="__ie_init") {
+                   s.parentNode.removeChild(s);
+               }
+           } catch(e) {
+               //pass
+           }
+            var e = new E(src, nativeEvent);
+            e.stop();
+            e.type = function () { return sig; };
+            if (typeof(func) == "string") {
+                return obj[func].apply(obj, [e]);
+            } else {
+                return func.apply(obj, [e]);
+            }
+       };
+    },
+
     _browserAlreadyHasMouseEnterAndLeave: function () {
         return /MSIE/.test(navigator.userAgent);
     },
@@ -625,7 +652,24 @@
             } else {
                 sig = "onmouseout";
             }
-        } else {
+        } else if (isDOM && sig === "onDOMContentLoaded"
+                  && !self._browserAlreadyHasDOMContentLoaded()) {
+           if (src.readyState) {
+               var listener = self._domContentLoadListener(src, sig,
func, obj);
+               //defer script hack for IE
+               if (src == document) {
+                   document.write("<script id=__ie_init defer=true
src=//:><\/script>");
+                   src = document.getElementById("__ie_init");
+               }
+               sig = "onreadystatechange";
+           } else {
+               var listener = self._listener(src, func, obj, isDOM);
+               sig = 'onload';
+               if (src == document) {
+                   src = window;
+               }
+           }
+       } else {
             var listener = self._listener(src, func, obj, isDOM);
         }

Index: DOM.js
===================================================================
--- DOM.js      (revision 1191)
+++ DOM.js      (working copy)
@@ -626,25 +626,32 @@
     /** @id MochiKit.DOM.addToCallStack */
     addToCallStack: function (target, path, func, once) {
         var self = MochiKit.DOM;
-        var existing = target[path];
-        var regfunc = existing;
-        if (!(typeof(existing) == 'function'
-                && typeof(existing.callStack) == "object"
-                && existing.callStack !== null)) {
-            regfunc = self._newCallStack(path, once);
-            if (typeof(existing) == 'function') {
-                regfunc.callStack.push(existing);
-            }
-            target[path] = regfunc;
-        }
-        regfunc.callStack.push(func);
+       if (MochiKit.Signal) {
+           MochiKit.Signal.connect(target, path, func);
+       } else {
+           var existing = target[path];
+           var regfunc = existing;
+           if (!(typeof(existing) == 'function'
+                 && typeof(existing.callStack) == "object"
+                 && existing.callStack !== null)) {
+               regfunc = self._newCallStack(path, once);
+               if (typeof(existing) == 'function') {
+                   regfunc.callStack.push(existing);
+               }
+               target[path] = regfunc;
+           }
+           regfunc.callStack.push(func);
+       }
     },

     /** @id MochiKit.DOM.addLoadEvent */
     addLoadEvent: function (func) {
         var self = MochiKit.DOM;
-        self.addToCallStack(self._window, "onload", func, true);
-
+       if (MochiKit.Signal) {
+           MochiKit.Signal.connect(self._document,
"onDOMContentLoaded", func);
+       } else {
+           self.addToCallStack(self._window, "onload", func, true);
+       }
     },

     /** @id MochiKit.DOM.focusOnLoad */


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to