support.js needs to come before event.js (also placed in a temporary setTimeout to...
[jquery.git] / src / support.js
index 332839d..b7da5e5 100644 (file)
@@ -5,7 +5,7 @@
        var root = document.documentElement,
                script = document.createElement("script"),
                div = document.createElement("div"),
-               id = "script" + (new Date).getTime();
+               id = "script" + now();
 
        div.style.display = "none";
        div.innerHTML = '   <link/><table></table><a href="/a" style="color:red;float:left;opacity:.55;">a</a><select><option>text</option></select>';
@@ -81,6 +81,8 @@
 
        // Figure out if the W3C box model works as expected
        // document.body must exist before we can do this
+       // TODO: This timeout is temporary until I move ready into core.js.
+       setTimeout(function(){
        jQuery(function(){
                var div = document.createElement("div");
                div.style.width = div.style.paddingLeft = "1px";
                document.body.removeChild( div ).style.display = 'none';
                div = null;
        });
+       }, 13);
+
+       // Technique from Juriy Zaytsev
+       // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
+       var eventSupported = function( eventName ) { 
+               var el = document.createElement("div"); 
+               eventName = "on" + eventName; 
+
+               var isSupported = (eventName in el); 
+               if ( !isSupported ) { 
+                       el.setAttribute(eventName, "return;"); 
+                       isSupported = typeof el[eventName] === "function"; 
+               } 
+               el = null; 
+
+               return isSupported; 
+       };
+       
+       jQuery.support.submitBubbles = eventSupported("submit");
+       jQuery.support.changeBubbles = eventSupported("change");
+       jQuery.support.focusBubbles = eventSupported("focus");
 
        // release memory in IE
        root = script = div = all = a = null;