1
- /**
2
- * Allow the test suite to run with other libs or jQuery's.
3
- */
4
- jQuery . noConflict ( ) ;
1
+ if ( typeof jQuery !== "undefined" ) {
2
+ /**
3
+ * Allow the test suite to run with other libs or jQuery's.
4
+ */
5
+ jQuery . noConflict ( ) ;
6
+
7
+ // Expose Sizzle for Sizzle's selector tests
8
+ // We remove Sizzle's globalization in jQuery
9
+ this . Sizzle = this . Sizzle || jQuery . find ;
10
+ }
5
11
6
12
// For checking globals pollution despite auto-created globals in various environments
7
- jQuery . each ( [ jQuery . expando , "getInterface" , "Packages" , "java" , "netscape" ] , function ( i , name ) {
13
+ supportjQuery . each ( [ jQuery . expando , "getInterface" , "Packages" , "java" , "netscape" ] , function ( i , name ) {
8
14
window [ name ] = window [ name ] ;
9
15
} ) ;
10
16
11
- // Expose Sizzle for Sizzle's selector tests
12
- // We remove Sizzle's globalization in jQuery
13
- var Sizzle = Sizzle || jQuery . find ,
14
-
15
17
// Allow subprojects to test against their own fixtures
16
- qunitModule = QUnit . module ,
18
+ var qunitModule = QUnit . module ,
17
19
qunitTest = QUnit . test ;
18
20
19
21
/**
@@ -53,7 +55,7 @@ this.testSubproject = function( label, url, risTests, complete ) {
53
55
54
56
// Find test function and wrap to require subproject fixture
55
57
for ( ; i >= 0 ; i -- ) {
56
- if ( originaljQuery . isFunction ( args [ i ] ) ) {
58
+ if ( supportjQuery . isFunction ( args [ i ] ) ) {
57
59
args [ i ] = requireFixture ( args [ i ] ) ;
58
60
break ;
59
61
}
@@ -64,15 +66,15 @@ this.testSubproject = function( label, url, risTests, complete ) {
64
66
65
67
// Load tests and fixture from subproject
66
68
// Test order matters, so we must be synchronous and throw an error on load failure
67
- originaljQuery . ajax ( url , {
69
+ supportjQuery . ajax ( url , {
68
70
async : false ,
69
71
dataType : "html" ,
70
72
error : function ( jqXHR , status ) {
71
73
throw new Error ( "Could not load: " + url + " (" + status + ")" ) ;
72
74
} ,
73
75
success : function ( data , status , jqXHR ) {
74
76
var sources = [ ] ,
75
- page = originaljQuery . parseHTML (
77
+ page = supportjQuery . parseHTML (
76
78
// replace html/head with dummy elements so they are represented in the DOM
77
79
( data || "" ) . replace ( / < \/ ? ( ( ! D O C T Y P E | h t m l | h e a d ) \b .* ?) > / gi, "[$1]" ) ,
78
80
document ,
@@ -82,11 +84,11 @@ this.testSubproject = function( label, url, risTests, complete ) {
82
84
if ( ! page || ! page . length ) {
83
85
this . error ( jqXHR , "no data" ) ;
84
86
}
85
- page = originaljQuery ( page ) ;
87
+ page = supportjQuery ( page ) ;
86
88
87
89
// Include subproject tests
88
90
page . filter ( "script[src]" ) . add ( page . find ( "script[src]" ) ) . map ( function ( ) {
89
- var src = originaljQuery ( this ) . attr ( "src" ) ;
91
+ var src = supportjQuery ( this ) . attr ( "src" ) ;
90
92
if ( risTests . test ( src ) ) {
91
93
sources . push ( src ) ;
92
94
}
@@ -123,7 +125,7 @@ this.testSubproject = function( label, url, risTests, complete ) {
123
125
}
124
126
125
127
// Replace the current fixture, including content outside of #qunit-fixture
126
- var oldFixture = originaljQuery ( "#qunit-fixture" ) ;
128
+ var oldFixture = supportjQuery ( "#qunit-fixture" ) ;
127
129
while ( oldFixture . length && ! oldFixture . prevAll ( "[id='qunit']" ) . length ) {
128
130
oldFixture = oldFixture . parent ( ) ;
129
131
}
@@ -133,7 +135,7 @@ this.testSubproject = function( label, url, risTests, complete ) {
133
135
// WARNING: UNDOCUMENTED INTERFACE
134
136
QUnit . config . fixture = fixtureHTML ;
135
137
QUnit . reset ( ) ;
136
- if ( originaljQuery ( "#qunit-fixture" ) . html ( ) !== fixtureHTML ) {
138
+ if ( supportjQuery ( "#qunit-fixture" ) . html ( ) !== fixtureHTML ) {
137
139
ok ( false , "Copied subproject fixture" ) ;
138
140
return ;
139
141
}
@@ -153,15 +155,15 @@ this.Globals = (function() {
153
155
return {
154
156
register : function ( name ) {
155
157
globals [ name ] = true ;
156
- jQuery . globalEval ( "var " + name + " = undefined;" ) ;
158
+ supportjQuery . globalEval ( "var " + name + " = undefined;" ) ;
157
159
} ,
158
160
cleanup : function ( ) {
159
161
var name ,
160
162
current = globals ;
161
163
globals = { } ;
162
164
for ( name in current ) {
163
- jQuery . globalEval ( "try { " +
164
- "delete " + ( jQuery . support . deleteExpando ? "window['" + name + "']" : name ) +
165
+ supportjQuery . globalEval ( "try { " +
166
+ "delete " + ( supportjQuery . support . deleteExpando ? "window['" + name + "']" : name ) +
165
167
"; } catch( x ) {}" ) ;
166
168
}
167
169
}
@@ -223,7 +225,7 @@ this.Globals = (function() {
223
225
if ( elems . jquery && elems . toArray ) {
224
226
elems = elems . toArray ( ) ;
225
227
}
226
- if ( ! jQuery . isArray ( elems ) ) {
228
+ if ( ! supportjQuery . isArray ( elems ) ) {
227
229
elems = [ elems ] ;
228
230
}
229
231
@@ -341,14 +343,16 @@ this.Globals = (function() {
341
343
342
344
QUnit . done ( function ( ) {
343
345
// Remove our own fixtures outside #qunit-fixture
344
- jQuery ( "#qunit ~ *" ) . remove ( ) ;
346
+ supportjQuery ( "#qunit ~ *" ) . remove ( ) ;
345
347
} ) ;
346
348
347
349
// jQuery-specific QUnit.reset
348
350
QUnit . reset = function ( ) {
349
351
350
352
// Ensure jQuery events and data on the fixture are properly removed
351
353
jQuery ( "#qunit-fixture" ) . empty ( ) ;
354
+ // ...even if the jQuery under test has a broken .empty()
355
+ supportjQuery ( "#qunit-fixture" ) . empty ( ) ;
352
356
353
357
// Reset internal jQuery state
354
358
jQuery . event . global = { } ;
0 commit comments