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],
17 select = document.createElement("select"),
18 opt = select.appendChild( document.createElement("option") );
20 // Can't get basic test support
21 if ( !all || !all.length || !a ) {
26 // IE strips leading whitespace when .innerHTML is used
27 leadingWhitespace: div.firstChild.nodeType === 3,
29 // Make sure that tbody elements aren't automatically inserted
30 // IE will insert them into empty tables
31 tbody: !div.getElementsByTagName("tbody").length,
33 // Make sure that link elements get serialized correctly by innerHTML
34 // This requires a wrapper element in IE
35 htmlSerialize: !!div.getElementsByTagName("link").length,
37 // Get the style information from getAttribute
38 // (IE uses .cssText insted)
39 style: /red/.test( a.getAttribute("style") ),
41 // Make sure that URLs aren't manipulated
42 // (IE normalizes it by default)
43 hrefNormalized: a.getAttribute("href") === "/a",
45 // Make sure that element opacity exists
46 // (IE uses filter instead)
47 // Use a regex to work around a WebKit issue. See #5145
48 opacity: /^0.55$/.test( a.style.opacity ),
50 // Verify style float existence
51 // (IE uses styleFloat instead of cssFloat)
52 cssFloat: !!a.style.cssFloat,
54 // Make sure that if no value is specified for a checkbox
55 // that it defaults to "on".
56 // (WebKit defaults to "" instead)
57 checkOn: div.getElementsByTagName("input")[0].value === "on",
59 // Make sure that a selected-by-default option has a working selected property.
60 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
61 optSelected: opt.selected,
63 // Will be defined later
69 inlineBlockNeedsLayout: false,
70 shrinkWrapBlocks: false,
71 reliableHiddenOffsets: true
74 // Make sure that the options inside disabled selects aren't marked as disabled
75 // (WebKit marks them as diabled)
76 select.disabled = true;
77 jQuery.support.optDisabled = !opt.disabled;
79 script.type = "text/javascript";
81 script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
84 root.insertBefore( script, root.firstChild );
86 // Make sure that the execution of code works by injecting a script
87 // tag with appendChild/createTextNode
88 // (IE doesn't support this, fails, and uses .text instead)
90 jQuery.support.scriptEval = true;
94 root.removeChild( script );
96 if ( div.attachEvent && div.fireEvent ) {
97 div.attachEvent("onclick", function click() {
98 // Cloning a node shouldn't copy over any
99 // bound event handlers (IE does this)
100 jQuery.support.noCloneEvent = false;
101 div.detachEvent("onclick", click);
103 div.cloneNode(true).fireEvent("onclick");
106 div = document.createElement("div");
107 div.innerHTML = "<input type='radio' name='radiotest' checked='checked'/>";
109 var fragment = document.createDocumentFragment();
110 fragment.appendChild( div.firstChild );
112 // WebKit doesn't clone checked state correctly in fragments
113 jQuery.support.checkClone = fragment.cloneNode(true).cloneNode(true).lastChild.checked;
115 // Figure out if the W3C box model works as expected
116 // document.body must exist before we can do this
118 var div = document.createElement("div");
119 div.style.width = div.style.paddingLeft = "1px";
121 document.body.appendChild( div );
122 jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
124 if ( "zoom" in div.style ) {
125 // Check if natively block-level elements act like inline-block
126 // elements when setting their display to 'inline' and giving
128 // (IE < 8 does this)
129 div.style.display = "inline";
131 jQuery.support.inlineBlockNeedsLayout = div.offsetWidth === 2;
133 // Check if elements with layout shrink-wrap their children
135 div.style.display = "";
136 div.innerHTML = "<div style='width:4px;'></div>";
137 jQuery.support.shrinkWrapBlocks = div.offsetWidth !== 2;
140 div.innerHTML = "<table><tr><td style='padding:0;display:none'></td><td>t</td></tr></table>";
141 var tds = div.getElementsByTagName("td");
143 // Check if table cells still have offsetWidth/Height when they are set
144 // to display:none and there are still other visible table cells in a
145 // table row; if so, offsetWidth/Height are not reliable for use when
146 // determining if an element has been hidden directly using
147 // display:none (it is still safe to use offsets if a parent element is
148 // hidden; don safety goggles and see bug #4512 for more information).
149 // (only IE 8 fails this test)
150 jQuery.support.reliableHiddenOffsets = tds[0].offsetHeight === 0;
152 tds[0].style.display = "";
153 tds[1].style.display = "none";
155 // Check if empty table cells still have offsetWidth/Height
156 // (IE < 8 fail this test)
157 jQuery.support.reliableHiddenOffsets = jQuery.support.reliableHiddenOffsets && tds[0].offsetHeight === 0;
160 document.body.removeChild( div ).style.display = "none";
164 // Technique from Juriy Zaytsev
165 // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
166 var eventSupported = function( eventName ) {
167 var el = document.createElement("div");
168 eventName = "on" + eventName;
170 var isSupported = (eventName in el);
171 if ( !isSupported ) {
172 el.setAttribute(eventName, "return;");
173 isSupported = typeof el[eventName] === "function";
180 jQuery.support.submitBubbles = eventSupported("submit");
181 jQuery.support.changeBubbles = eventSupported("change");
183 // release memory in IE
184 root = script = div = all = a = null;
189 "class": "className",
190 readonly: "readOnly",
191 maxlength: "maxLength",
192 cellspacing: "cellSpacing",
195 tabindex: "tabIndex",
197 frameborder: "frameBorder"