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