1
1
module ( "selector" ) ;
2
2
3
3
test ( "element" , function ( ) {
4
- expect ( 18 ) ;
5
- QUnit . reset ( ) ;
4
+ expect ( 19 ) ;
5
+ reset ( ) ;
6
6
7
7
ok ( jQuery ( "*" ) . size ( ) >= 30 , "Select all" ) ;
8
8
var all = jQuery ( "*" ) , good = true ;
@@ -21,13 +21,14 @@ test("element", function() {
21
21
same ( jQuery ( "p" , jQuery ( "div" ) ) . get ( ) , q ( "firstp" , "ap" , "sndp" , "en" , "sap" , "first" ) , "Finding elements with a context." ) ;
22
22
same ( jQuery ( "div" ) . find ( "p" ) . get ( ) , q ( "firstp" , "ap" , "sndp" , "en" , "sap" , "first" ) , "Finding elements with a context." ) ;
23
23
24
- same ( jQuery ( "#form" ) . find ( "select" ) . get ( ) , q ( "select1" , "select2" , "select3" , "select4" , "select5" ) , "Finding selects with a context." ) ;
24
+ same ( jQuery ( "#form" ) . find ( "select" ) . get ( ) , q ( "select1" , "select2" , "select3" ) , "Finding selects with a context." ) ;
25
25
26
26
ok ( jQuery ( "#length" ) . length , '<input name="length"> cannot be found under IE, see #945' ) ;
27
27
ok ( jQuery ( "#lengthtest input" ) . length , '<input name="length"> cannot be found under IE, see #945' ) ;
28
28
29
29
// Check for unique-ness and sort order
30
- same ( jQuery ( "p, div p" ) . get ( ) , jQuery ( "p" ) . get ( ) , "Check for duplicates: p, div p" ) ;
30
+ same ( jQuery ( "*" ) . get ( ) , jQuery ( "*, *" ) . get ( ) , "Check for duplicates: *, *" ) ;
31
+ same ( jQuery ( "p" ) . get ( ) , jQuery ( "p, div p" ) . get ( ) , "Check for duplicates: p, div p" ) ;
31
32
32
33
t ( "Checking sort order" , "h2, h1" , [ "qunit-header" , "qunit-banner" , "qunit-userAgent" ] ) ;
33
34
t ( "Checking sort order" , "h2:first, h1:first" , [ "qunit-header" , "qunit-banner" ] ) ;
@@ -36,7 +37,7 @@ test("element", function() {
36
37
37
38
if ( location . protocol != "file:" ) {
38
39
test ( "XML Document Selectors" , function ( ) {
39
- expect ( 8 ) ;
40
+ expect ( 7 ) ;
40
41
stop ( ) ;
41
42
jQuery . get ( "data/with_fries.xml" , function ( xml ) {
42
43
equals ( jQuery ( "foo_bar" , xml ) . length , 1 , "Element Selector with underscore" ) ;
@@ -46,7 +47,6 @@ if ( location.protocol != "file:" ) {
46
47
equals ( jQuery ( "[name=prop2]" , xml ) . length , 1 , "Attribute selector with name" ) ;
47
48
equals ( jQuery ( "#seite1" , xml ) . length , 1 , "Attribute selector with ID" ) ;
48
49
equals ( jQuery ( "component#seite1" , xml ) . length , 1 , "Attribute selector with ID" ) ;
49
- equals ( jQuery ( "component" , xml ) . filter ( "#seite1" ) . length , 1 , "Attribute selector filter with ID" ) ;
50
50
start ( ) ;
51
51
} ) ;
52
52
} ) ;
@@ -154,7 +154,7 @@ test("class", function() {
154
154
} ) ;
155
155
156
156
test ( "name" , function ( ) {
157
- expect ( 15 ) ;
157
+ expect ( 14 ) ;
158
158
159
159
t ( "Name selector" , "input[name=action]" , [ "text1" ] ) ;
160
160
t ( "Name selector with single quotes" , "input[name='action']" , [ "text1" ] ) ;
@@ -169,19 +169,13 @@ test("name", function() {
169
169
same ( jQuery ( "#form" ) . find ( "input[name=action]" ) . get ( ) , q ( "text1" ) , "Name selector within the context of another element" ) ;
170
170
same ( jQuery ( "#form" ) . find ( "input[name='foo[bar]']" ) . get ( ) , q ( "hidden2" ) , "Name selector for grouped form element within the context of another element" ) ;
171
171
172
- var form = jQuery ( "<form><input name='id'/></form>" ) . appendTo ( "body" ) ;
173
-
174
- equals ( form . find ( "input" ) . length , 1 , "Make sure that rooted queries on forms (with possible expandos) work." ) ;
175
-
176
- form . remove ( ) ;
177
-
178
172
var a = jQuery ( '<div><a id="tName1ID" name="tName1">tName1 A</a><a id="tName2ID" name="tName2">tName2 A</a><div id="tName1">tName1 Div</div></div>' ) . appendTo ( '#main' ) . children ( ) ;
179
173
180
174
equals ( a . length , 3 , "Make sure the right number of elements were inserted." ) ;
181
175
equals ( a [ 1 ] . id , "tName2ID" , "Make sure the right number of elements were inserted." ) ;
182
176
183
- equals ( jQuery ( "[name=tName1]" ) [ 0 ] , a [ 0 ] , " Find elements that have similar IDs" ) ;
184
- equals ( jQuery ( "[name=tName2]" ) [ 0 ] , a [ 1 ] , " Find elements that have similar IDs" ) ;
177
+ t ( " Find elements that have similar IDs", "[name=tName1]" , [ "tName1ID" ] ) ;
178
+ t ( " Find elements that have similar IDs", "[name=tName2]" , [ "tName2ID" ] ) ;
185
179
t ( "Find elements that have similar IDs" , "#tName2ID" , [ "tName2ID" ] ) ;
186
180
187
181
a . remove ( ) ;
@@ -197,7 +191,7 @@ test("multiple", function() {
197
191
} ) ;
198
192
199
193
test ( "child and adjacent" , function ( ) {
200
- expect ( 27 ) ;
194
+ expect ( 29 ) ;
201
195
t ( "Child" , "p > a" , [ "simon1" , "google" , "groups" , "mark" , "yahoo" , "simon" ] ) ;
202
196
t ( "Child" , "p> a" , [ "simon1" , "google" , "groups" , "mark" , "yahoo" , "simon" ] ) ;
203
197
t ( "Child" , "p >a" , [ "simon1" , "google" , "groups" , "mark" , "yahoo" , "simon" ] ) ;
@@ -209,6 +203,7 @@ test("child and adjacent", function() {
209
203
t ( "Adjacent" , "a +a" , [ "groups" ] ) ;
210
204
t ( "Adjacent" , "a+ a" , [ "groups" ] ) ;
211
205
t ( "Adjacent" , "a+a" , [ "groups" ] ) ;
206
+ t ( "Adjacent" , "a:eq(1)+a" , [ "groups" ] ) ;
212
207
t ( "Adjacent" , "p + p" , [ "ap" , "en" , "sap" ] ) ;
213
208
t ( "Adjacent" , "p#firstp + p" , [ "ap" ] ) ;
214
209
t ( "Adjacent" , "p[lang=en] + p" , [ "sap" ] ) ;
@@ -219,6 +214,7 @@ test("child and adjacent", function() {
219
214
t ( "Element Preceded By" , "#groups ~ a" , [ "mark" ] ) ;
220
215
t ( "Element Preceded By" , "#length ~ input" , [ "idTest" ] ) ;
221
216
t ( "Element Preceded By" , "#siblingfirst ~ em" , [ "siblingnext" ] ) ;
217
+ t ( "Element Preceded By" , "#siblingfirst:first ~ em" , [ "siblingnext" ] ) ;
222
218
223
219
t ( "Verify deep class selector" , "div.blah > p > a" , [ ] ) ;
224
220
@@ -232,7 +228,7 @@ test("child and adjacent", function() {
232
228
} ) ;
233
229
234
230
test ( "attributes" , function ( ) {
235
- expect ( 35 ) ;
231
+ expect ( 34 ) ;
236
232
t ( "Attribute Exists" , "a[title]" , [ "google" ] ) ;
237
233
t ( "Attribute Exists" , "*[title]" , [ "google" ] ) ;
238
234
t ( "Attribute Exists" , "[title]" , [ "google" ] ) ;
@@ -270,9 +266,6 @@ test("attributes", function() {
270
266
t ( "Attribute Contains" , "a[href *= 'google']" , [ "google" , "groups" ] ) ;
271
267
t ( "Attribute Is Not Equal" , "#ap a[hreflang!='en']" , [ "google" , "groups" , "anchor1" ] ) ;
272
268
273
- var opt = document . getElementById ( "option1a" ) ;
274
- ok ( ( window . Sizzle || window . jQuery . find ) . matchesSelector ( opt , "[id*=option1][type!=checkbox]" ) , "Attribute Is Not Equal Matches" ) ;
275
-
276
269
t ( "Empty values" , "#select1 option[value='']" , [ "option1a" ] ) ;
277
270
t ( "Empty values" , "#select1 option[value!='']" , [ "option1b" , "option1c" , "option1d" ] ) ;
278
271
@@ -287,7 +280,7 @@ test("pseudo - child", function() {
287
280
expect ( 31 ) ;
288
281
t ( "First Child" , "p:first-child" , [ "firstp" , "sndp" ] ) ;
289
282
t ( "Last Child" , "p:last-child" , [ "sap" ] ) ;
290
- t ( "Only Child" , "#main a:only-child" , [ "simon1" , "anchor1" , "yahoo" , "anchor2" , "liveLink1" , "liveLink2" ] ) ;
283
+ t ( "Only Child" , "a:only-child" , [ "simon1" , "anchor1" , "yahoo" , "anchor2" , "liveLink1" , "liveLink2" ] ) ;
291
284
t ( "Empty" , "ul:empty" , [ "firstUL" ] ) ;
292
285
t ( "Is A Parent" , "p:parent" , [ "firstp" , "ap" , "sndp" , "en" , "sap" , "first" ] ) ;
293
286
@@ -301,10 +294,10 @@ test("pseudo - child", function() {
301
294
302
295
t ( "First Child" , "p:first-child" , [ ] ) ;
303
296
304
- QUnit . reset ( ) ;
297
+ reset ( ) ;
305
298
306
299
t ( "Last Child" , "p:last-child" , [ "sap" ] ) ;
307
- t ( "Last Child" , "#main a:last-child" , [ "simon1" , "anchor1" , "mark" , "yahoo" , "anchor2" , "simon" , "liveLink1" , "liveLink2" ] ) ;
300
+ t ( "Last Child" , "a:last-child" , [ "simon1" , "anchor1" , "mark" , "yahoo" , "anchor2" , "simon" , "liveLink1" , "liveLink2" ] ) ;
308
301
309
302
t ( "Nth-child" , "#main form#form > *:nth-child(2)" , [ "text1" ] ) ;
310
303
t ( "Nth-child" , "#main form#form > :nth-child(2)" , [ "text1" ] ) ;
@@ -330,27 +323,23 @@ test("pseudo - child", function() {
330
323
} ) ;
331
324
332
325
test ( "pseudo - misc" , function ( ) {
333
- expect ( 7 ) ;
326
+ expect ( 6 ) ;
334
327
335
328
t ( "Headers" , ":header" , [ "qunit-header" , "qunit-banner" , "qunit-userAgent" ] ) ;
336
329
t ( "Has Children - :has()" , "p:has(a)" , [ "firstp" , "ap" , "en" , "sap" ] ) ;
337
-
338
- var select = document . getElementById ( "select1" ) ;
339
- ok ( ( window . Sizzle || window . jQuery . find ) . matchesSelector ( select , ":has(option)" ) , "Has Option Matches" ) ;
340
330
341
- t ( "Text Contains" , "a:contains(Google)" , [ "google" , "groups" ] ) ;
342
- t ( "Text Contains" , "a:contains(Google Groups)" , [ "groups" ] ) ;
331
+ t ( "Text Contains" , "a:contains(' Google' )" , [ "google" , "groups" ] ) ;
332
+ t ( "Text Contains" , "a:contains(' Google Groups' )" , [ "groups" ] ) ;
343
333
344
- t ( "Text Contains" , "a:contains(Google Groups (Link))" , [ "groups" ] ) ;
345
- t ( "Text Contains" , "a:contains((Link))" , [ "groups" ] ) ;
334
+ t ( "Text Contains" , "a:contains(' Google Groups (Link)' )" , [ "groups" ] ) ;
335
+ t ( "Text Contains" , "a:contains(' (Link)' )" , [ "groups" ] ) ;
346
336
} ) ;
347
337
348
338
349
339
test ( "pseudo - :not" , function ( ) {
350
340
expect ( 24 ) ;
351
341
t ( "Not" , "a.blog:not(.link)" , [ "mark" ] ) ;
352
-
353
- t ( "Not - multiple" , "#form option:not(:contains(Nothing),#option1b,:selected)" , [ "option1c" , "option1d" , "option2b" , "option2c" , "option3d" , "option3e" , "option4e" , "option5b" , "option5c" ] ) ;
342
+ t ( "Not - multiple" , "#form option:not(:contains('Nothing'),#option1b,:selected)" , [ "option1c" , "option1d" , "option2b" , "option2c" , "option3d" , "option3e" ] ) ;
354
343
t ( "Not - recursive" , "#form option:not(:not(:selected))[id^='option3']" , [ "option3b" , "option3c" ] ) ;
355
344
356
345
t ( ":not() failing interior" , "p:not(.foo)" , [ "firstp" , "ap" , "sndp" , "en" , "sap" , "first" ] ) ;
@@ -371,9 +360,9 @@ test("pseudo - :not", function() {
371
360
372
361
t ( "No element not selector" , ".container div:not(.excluded) div" , [ ] ) ;
373
362
374
- t ( ":not() Existing attribute" , "#form select:not([multiple])" , [ "select1" , "select2" , "select5" ] ) ;
375
- t ( ":not() Equals attribute" , "#form select:not([name=select1])" , [ "select2" , "select3" , "select4" , "select5" ] ) ;
376
- t ( ":not() Equals quoted attribute" , "#form select:not([name='select1'])" , [ "select2" , "select3" , "select4" , "select5" ] ) ;
363
+ t ( ":not() Existing attribute" , "#form select:not([multiple])" , [ "select1" , "select2" ] ) ;
364
+ t ( ":not() Equals attribute" , "#form select:not([name=select1])" , [ "select2" , "select3" ] ) ;
365
+ t ( ":not() Equals quoted attribute" , "#form select:not([name='select1'])" , [ "select2" , "select3" ] ) ;
377
366
378
367
t ( ":not() Multiple Class" , "#foo a:not(.blog)" , [ "yahoo" , "anchor2" ] ) ;
379
368
t ( ":not() Multiple Class" , "#foo a:not(.link)" , [ "yahoo" , "anchor2" ] ) ;
@@ -439,13 +428,13 @@ test("pseudo - visibility", function() {
439
428
test ( "pseudo - form" , function ( ) {
440
429
expect ( 8 ) ;
441
430
442
- t ( "Form element :input" , "#form :input" , [ "text1" , "text2" , "radio1" , "radio2" , "check1" , "check2" , "hidden1" , "hidden2" , "name" , "search" , "button" , "area1" , "select1" , "select2" , "select3" , "select4" , "select5" ] ) ;
431
+ t ( "Form element :input" , "#form :input" , [ "text1" , "text2" , "radio1" , "radio2" , "check1" , "check2" , "hidden1" , "hidden2" , "name" , "search" , "button" , "area1" , "select1" , "select2" , "select3" ] ) ;
443
432
t ( "Form element :radio" , "#form :radio" , [ "radio1" , "radio2" ] ) ;
444
433
t ( "Form element :checkbox" , "#form :checkbox" , [ "check1" , "check2" ] ) ;
445
434
t ( "Form element :text" , "#form :text:not(#search)" , [ "text1" , "text2" , "hidden2" , "name" ] ) ;
446
435
t ( "Form element :radio:checked" , "#form :radio:checked" , [ "radio2" ] ) ;
447
436
t ( "Form element :checkbox:checked" , "#form :checkbox:checked" , [ "check1" ] ) ;
448
437
t ( "Form element :radio:checked, :checkbox:checked" , "#form :radio:checked, #form :checkbox:checked" , [ "radio2" , "check1" ] ) ;
449
438
450
- t ( "Selected Option Element" , "#form option:selected" , [ "option1a" , "option2d" , "option3b" , "option3c" , "option4b" , "option4c" , "option4d" , "option5a" ] ) ;
439
+ t ( "Selected Option Element" , "#form option:selected" , [ "option1a" , "option2d" , "option3b" , "option3c" ] ) ;
451
440
} ) ;
0 commit comments