5 var root = document.documentElement,
6 script = document.createElement("script"),
7 div = document.createElement("div"),
8 id = "script" + jQuery.now();
10 div.style.display = "none";
11 div.innerHTML = " <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
13 var all = div.getElementsByTagName("*"),
14 a = div.getElementsByTagName("a")[0];
16 // Can't get basic test support
17 if ( !all || !all.length || !a ) {
22 // IE strips leading whitespace when .innerHTML is used
23 leadingWhitespace: div.firstChild.nodeType === 3,
25 // Make sure that tbody elements aren't automatically inserted
26 // IE will insert them into empty tables
27 tbody: !div.getElementsByTagName("tbody").length,
29 // Make sure that link elements get serialized correctly by innerHTML
30 // This requires a wrapper element in IE
31 htmlSerialize: !!div.getElementsByTagName("link").length,
33 // Get the style information from getAttribute
34 // (IE uses .cssText insted)
35 style: /red/.test( a.getAttribute("style") ),
37 // Make sure that URLs aren't manipulated
38 // (IE normalizes it by default)
39 hrefNormalized: a.getAttribute("href") === "/a",
41 // Make sure that element opacity exists
42 // (IE uses filter instead)
43 // Use a regex to work around a WebKit issue. See #5145
44 opacity: /^0.55$/.test( a.style.opacity ),
46 // Verify style float existence
47 // (IE uses styleFloat instead of cssFloat)
48 cssFloat: !!a.style.cssFloat,
50 // Make sure that if no value is specified for a checkbox
51 // that it defaults to "on".
52 // (WebKit defaults to "" instead)
53 checkOn: div.getElementsByTagName("input")[0].value === "on",
55 // Make sure that a selected-by-default option has a working selected property.
56 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
57 optSelected: document.createElement("select").appendChild( document.createElement("option") ).selected,
59 // Will be defined later
66 script.type = "text/javascript";
68 script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
71 root.insertBefore( script, root.firstChild );
73 // Make sure that the execution of code works by injecting a script
74 // tag with appendChild/createTextNode
75 // (IE doesn't support this, fails, and uses .text instead)
77 jQuery.support.scriptEval = true;
81 root.removeChild( script );
83 if ( div.attachEvent && div.fireEvent ) {
84 div.attachEvent("onclick", function click() {
85 // Cloning a node shouldn't copy over any
86 // bound event handlers (IE does this)
87 jQuery.support.noCloneEvent = false;
88 div.detachEvent("onclick", click);
90 div.cloneNode(true).fireEvent("onclick");
93 div = document.createElement("div");
94 div.innerHTML = "<input type='radio' name='radiotest' checked='checked'/>";
96 var fragment = document.createDocumentFragment();
97 fragment.appendChild( div.firstChild );
99 // WebKit doesn't clone checked state correctly in fragments
100 jQuery.support.checkClone = fragment.cloneNode(true).cloneNode(true).lastChild.checked;
102 // Figure out if the W3C box model works as expected
103 // document.body must exist before we can do this
105 var div = document.createElement("div");
106 div.style.width = div.style.paddingLeft = "1px";
108 document.body.appendChild( div );
109 jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
110 document.body.removeChild( div ).style.display = 'none';
114 // Technique from Juriy Zaytsev
115 // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
116 var eventSupported = function( eventName ) {
117 var el = document.createElement("div");
118 eventName = "on" + eventName;
120 var isSupported = (eventName in el);
121 if ( !isSupported ) {
122 el.setAttribute(eventName, "return;");
123 isSupported = typeof el[eventName] === "function";
130 jQuery.support.submitBubbles = eventSupported("submit");
131 jQuery.support.changeBubbles = eventSupported("change");
133 // release memory in IE
134 root = script = div = all = a = null;
139 "class": "className",
140 readonly: "readOnly",
141 maxlength: "maxLength",
142 cellspacing: "cellSpacing",
145 tabindex: "tabIndex",
147 frameborder: "frameBorder"