7 var div = document.createElement("div");
9 div.style.display = "none";
10 div.innerHTML = " <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
12 var all = div.getElementsByTagName("*"),
13 a = div.getElementsByTagName("a")[0],
14 select = document.createElement("select"),
15 opt = select.appendChild( document.createElement("option") ),
16 input = div.getElementsByTagName("input")[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: input.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: opt.selected,
61 // Will be defined later
68 inlineBlockNeedsLayout: false,
69 shrinkWrapBlocks: false,
70 reliableHiddenOffsets: true
74 jQuery.support.noCloneChecked = input.cloneNode( true ).checked;
76 // Make sure that the options inside disabled selects aren't marked as disabled
77 // (WebKit marks them as diabled)
78 select.disabled = true;
79 jQuery.support.optDisabled = !opt.disabled;
81 var _scriptEval = null;
82 jQuery.support.scriptEval = function() {
83 if ( _scriptEval === null ) {
84 var root = document.documentElement,
85 script = document.createElement("script"),
86 id = "script" + jQuery.now();
89 script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
92 root.insertBefore( script, root.firstChild );
94 // Make sure that the execution of code works by injecting a script
95 // tag with appendChild/createTextNode
96 // (IE doesn't support this, fails, and uses .text instead)
104 root.removeChild( script );
105 // release memory in IE
106 root = script = id = null;
112 // Test to see if it's possible to delete an expando from an element
113 // Fails in Internet Explorer
118 jQuery.support.deleteExpando = false;
121 if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
122 div.attachEvent("onclick", function click() {
123 // Cloning a node shouldn't copy over any
124 // bound event handlers (IE does this)
125 jQuery.support.noCloneEvent = false;
126 div.detachEvent("onclick", click);
128 div.cloneNode(true).fireEvent("onclick");
131 div = document.createElement("div");
132 div.innerHTML = "<input type='radio' name='radiotest' checked='checked'/>";
134 var fragment = document.createDocumentFragment();
135 fragment.appendChild( div.firstChild );
137 // WebKit doesn't clone checked state correctly in fragments
138 jQuery.support.checkClone = fragment.cloneNode(true).cloneNode(true).lastChild.checked;
140 // Figure out if the W3C box model works as expected
141 // document.body must exist before we can do this
143 var div = document.createElement("div"),
144 body = document.getElementsByTagName("body")[0];
146 // Frameset documents with no body should not run this code
151 div.style.width = div.style.paddingLeft = "1px";
152 body.appendChild( div );
153 jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
155 if ( "zoom" in div.style ) {
156 // Check if natively block-level elements act like inline-block
157 // elements when setting their display to 'inline' and giving
159 // (IE < 8 does this)
160 div.style.display = "inline";
162 jQuery.support.inlineBlockNeedsLayout = div.offsetWidth === 2;
164 // Check if elements with layout shrink-wrap their children
166 div.style.display = "";
167 div.innerHTML = "<div style='width:4px;'></div>";
168 jQuery.support.shrinkWrapBlocks = div.offsetWidth !== 2;
171 div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";
172 var tds = div.getElementsByTagName("td");
174 // Check if table cells still have offsetWidth/Height when they are set
175 // to display:none and there are still other visible table cells in a
176 // table row; if so, offsetWidth/Height are not reliable for use when
177 // determining if an element has been hidden directly using
178 // display:none (it is still safe to use offsets if a parent element is
179 // hidden; don safety goggles and see bug #4512 for more information).
180 // (only IE 8 fails this test)
181 jQuery.support.reliableHiddenOffsets = tds[0].offsetHeight === 0;
183 tds[0].style.display = "";
184 tds[1].style.display = "none";
186 // Check if empty table cells still have offsetWidth/Height
187 // (IE < 8 fail this test)
188 jQuery.support.reliableHiddenOffsets = jQuery.support.reliableHiddenOffsets && tds[0].offsetHeight === 0;
191 body.removeChild( div ).style.display = "none";
195 // Technique from Juriy Zaytsev
196 // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
197 var eventSupported = function( eventName ) {
198 var el = document.createElement("div");
199 eventName = "on" + eventName;
201 // We only care about the case where non-standard event systems
202 // are used, namely in IE. Short-circuiting here helps us to
203 // avoid an eval call (in setAttribute) which can cause CSP
204 // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
205 if ( !el.attachEvent ) {
209 var isSupported = (eventName in el);
210 if ( !isSupported ) {
211 el.setAttribute(eventName, "return;");
212 isSupported = typeof el[eventName] === "function";
219 jQuery.support.submitBubbles = eventSupported("submit");
220 jQuery.support.changeBubbles = eventSupported("change");
222 // release memory in IE
223 div = all = a = null;