Skip to content

Commit 22fac5c

Browse files
gibson042dmethvin
authored andcommitted
Fix #12357: be more kind to non-browser environments. Close jquerygh-938.
1 parent f9ef91d commit 22fac5c

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/support.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,23 @@ jQuery.support = (function() {
1313
clickFn,
1414
div = document.createElement("div");
1515

16-
// Preliminary tests
16+
// Setup
1717
div.setAttribute( "className", "t" );
1818
div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
1919

20+
// Support tests won't run in some limited or non-browser environments
2021
all = div.getElementsByTagName("*");
2122
a = div.getElementsByTagName("a")[ 0 ];
22-
a.style.cssText = "top:1px;float:left;opacity:.5";
23-
24-
// Can't get basic test support
25-
if ( !all || !all.length ) {
23+
if ( !all || !a || !all.length ) {
2624
return {};
2725
}
2826

29-
// First batch of supports tests
27+
// First batch of tests
3028
select = document.createElement("select");
3129
opt = select.appendChild( document.createElement("option") );
3230
input = div.getElementsByTagName("input")[ 0 ];
3331

32+
a.style.cssText = "top:1px;float:left;opacity:.5";
3433
support = {
3534
// IE strips leading whitespace when .innerHTML is used
3635
leadingWhitespace: ( div.firstChild.nodeType === 3 ),
@@ -72,7 +71,7 @@ jQuery.support = (function() {
7271
// Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
7372
getSetAttribute: div.className !== "t",
7473

75-
// Tests for enctype support on a form(#6743)
74+
// Tests for enctype support on a form (#6743)
7675
enctype: !!document.createElement("form").enctype,
7776

7877
// Makes sure cloning an html5 element does not cause problems

0 commit comments

Comments
 (0)