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