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,
71 reliableMarginRight: true
75 jQuery.support.noCloneChecked = input.cloneNode( true ).checked;
77 // Make sure that the options inside disabled selects aren't marked as disabled
78 // (WebKit marks them as diabled)
79 select.disabled = true;
80 jQuery.support.optDisabled = !opt.disabled;
82 var _scriptEval = null;
83 jQuery.support.scriptEval = function() {
84 if ( _scriptEval === null ) {
85 var root = document.documentElement,
86 script = document.createElement("script"),
87 id = "script" + jQuery.now();
90 script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
93 root.insertBefore( script, root.firstChild );
95 // Make sure that the execution of code works by injecting a script
96 // tag with appendChild/createTextNode
97 // (IE doesn't support this, fails, and uses .text instead)
105 root.removeChild( script );
106 // release memory in IE
107 root = script = id = null;
113 // Test to see if it's possible to delete an expando from an element
114 // Fails in Internet Explorer
119 jQuery.support.deleteExpando = false;
122 if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
123 div.attachEvent("onclick", function click() {
124 // Cloning a node shouldn't copy over any
125 // bound event handlers (IE does this)
126 jQuery.support.noCloneEvent = false;
127 div.detachEvent("onclick", click);
129 div.cloneNode(true).fireEvent("onclick");
132 div = document.createElement("div");
133 div.innerHTML = "<input type='radio' name='radiotest' checked='checked'/>";
135 var fragment = document.createDocumentFragment();
136 fragment.appendChild( div.firstChild );
138 // WebKit doesn't clone checked state correctly in fragments
139 jQuery.support.checkClone = fragment.cloneNode(true).cloneNode(true).lastChild.checked;
141 // Figure out if the W3C box model works as expected
142 // document.body must exist before we can do this
144 var div = document.createElement("div"),
145 body = document.getElementsByTagName("body")[0];
147 // Frameset documents with no body should not run this code
152 div.style.width = div.style.paddingLeft = "1px";
153 body.appendChild( div );
154 jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
156 if ( "zoom" in div.style ) {
157 // Check if natively block-level elements act like inline-block
158 // elements when setting their display to 'inline' and giving
160 // (IE < 8 does this)
161 div.style.display = "inline";
163 jQuery.support.inlineBlockNeedsLayout = div.offsetWidth === 2;
165 // Check if elements with layout shrink-wrap their children
167 div.style.display = "";
168 div.innerHTML = "<div style='width:4px;'></div>";
169 jQuery.support.shrinkWrapBlocks = div.offsetWidth !== 2;
172 div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";
173 var tds = div.getElementsByTagName("td");
175 // Check if table cells still have offsetWidth/Height when they are set
176 // to display:none and there are still other visible table cells in a
177 // table row; if so, offsetWidth/Height are not reliable for use when
178 // determining if an element has been hidden directly using
179 // display:none (it is still safe to use offsets if a parent element is
180 // hidden; don safety goggles and see bug #4512 for more information).
181 // (only IE 8 fails this test)
182 jQuery.support.reliableHiddenOffsets = tds[0].offsetHeight === 0;
184 tds[0].style.display = "";
185 tds[1].style.display = "none";
187 // Check if empty table cells still have offsetWidth/Height
188 // (IE < 8 fail this test)
189 jQuery.support.reliableHiddenOffsets = jQuery.support.reliableHiddenOffsets && tds[0].offsetHeight === 0;
192 // Check if div with explicit width and no margin-right incorrectly
193 // gets computed margin-right based on width of container. For more
194 // info see bug #3333
195 // Fails in WebKit before Feb 2011 nightlies
196 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
197 if ( document.defaultView && document.defaultView.getComputedStyle ) {
198 div.style.width = "1px";
199 div.style.marginRight = "0";
200 jQuery.support.reliableMarginRight = ( parseInt(document.defaultView.getComputedStyle(div).marginRight, 10) || 0 ) === 0;
203 body.removeChild( div ).style.display = "none";
207 // Technique from Juriy Zaytsev
208 // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
209 var eventSupported = function( eventName ) {
210 var el = document.createElement("div");
211 eventName = "on" + eventName;
213 // We only care about the case where non-standard event systems
214 // are used, namely in IE. Short-circuiting here helps us to
215 // avoid an eval call (in setAttribute) which can cause CSP
216 // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
217 if ( !el.attachEvent ) {
221 var isSupported = (eventName in el);
222 if ( !isSupported ) {
223 el.setAttribute(eventName, "return;");
224 isSupported = typeof el[eventName] === "function";
231 jQuery.support.submitBubbles = eventSupported("submit");
232 jQuery.support.changeBubbles = eventSupported("change");
234 // release memory in IE
235 div = all = a = null;