@@ -71,16 +71,16 @@ test( "attr(String)", function() {
71
71
equal ( jQuery ( "#text1" ) . attr ( "value" , "" ) . attr ( "value" ) , "" , "Check setting the value attribute to empty string" ) ;
72
72
equal ( jQuery ( "<div value='t'></div>" ) . attr ( "value" ) , "t" , "Check setting custom attr named 'value' on a div" ) ;
73
73
equal ( jQuery ( "#form" ) . attr ( "blah" , "blah" ) . attr ( "blah" ) , "blah" , "Set non-existent attribute on a form" ) ;
74
- equal ( jQuery ( "#foo" ) . attr ( "height" ) , undefined , "Non existent height attribute should return undefined " ) ;
74
+ equal ( jQuery ( "#foo" ) . attr ( "height" ) , null , "Non existent height attribute should return null " ) ;
75
75
76
76
// [7472] & [3113] (form contains an input with name="action" or name="id")
77
77
extras = jQuery ( "<input id='id' name='id' /><input id='name' name='name' /><input id='target' name='target' />" ) . appendTo ( "#testForm" ) ;
78
78
equal ( jQuery ( "#form" ) . attr ( "action" , "newformaction" ) . attr ( "action" ) , "newformaction" , "Check that action attribute was changed" ) ;
79
- equal ( jQuery ( "#testForm" ) . attr ( "target" ) , undefined , "Retrieving target does not equal the input with name=target" ) ;
79
+ equal ( jQuery ( "#testForm" ) . attr ( "target" ) , null , "Retrieving target does not equal the input with name=target" ) ;
80
80
equal ( jQuery ( "#testForm" ) . attr ( "target" , "newTarget" ) . attr ( "target" ) , "newTarget" , "Set target successfully on a form" ) ;
81
- equal ( jQuery ( "#testForm" ) . removeAttr ( "id" ) . attr ( "id" ) , undefined , "Retrieving id does not equal the input with name=id after id is removed [#7472]" ) ;
81
+ equal ( jQuery ( "#testForm" ) . removeAttr ( "id" ) . attr ( "id" ) , null , "Retrieving id does not equal the input with name=id after id is removed [#7472]" ) ;
82
82
// Bug #3685 (form contains input with name="name")
83
- equal ( jQuery ( "#testForm" ) . attr ( "name" ) , undefined , "Retrieving name does not retrieve input with name=name" ) ;
83
+ equal ( jQuery ( "#testForm" ) . attr ( "name" ) , null , "Retrieving name does not retrieve input with name=name" ) ;
84
84
extras . remove ( ) ;
85
85
86
86
equal ( jQuery ( "#text1" ) . attr ( "maxlength" ) , "30" , "Check for maxlength attribute" ) ;
@@ -107,7 +107,7 @@ test( "attr(String)", function() {
107
107
body = document . body ;
108
108
$body = jQuery ( body ) ;
109
109
110
- strictEqual ( $body . attr ( "foo" ) , undefined , "Make sure that a non existent attribute returns undefined " ) ;
110
+ strictEqual ( $body . attr ( "foo" ) , null , "Make sure that a non existent attribute returns null " ) ;
111
111
112
112
body . setAttribute ( "foo" , "baz" ) ;
113
113
equal ( $body . attr ( "foo" ) , "baz" , "Make sure the dom attribute is retrieved when no expando is found" ) ;
@@ -139,12 +139,12 @@ test( "attr(String)", function() {
139
139
140
140
// Check value on button element (#1954)
141
141
$button = jQuery ( "<button>text</button>" ) . insertAfter ( "#button" ) ;
142
- strictEqual ( $button . attr ( "value" ) , undefined , "Absence of value attribute on a button" ) ;
142
+ strictEqual ( $button . attr ( "value" ) , null , "Absence of value attribute on a button" ) ;
143
143
equal ( $button . attr ( "value" , "foobar" ) . attr ( "value" ) , "foobar" , "Value attribute on a button does not return innerHTML" ) ;
144
144
equal ( $button . attr ( "value" , "baz" ) . html ( ) , "text" , "Setting the value attribute does not change innerHTML" ) ;
145
145
146
146
// Attributes with a colon on a table element (#1591)
147
- equal ( jQuery ( "#table" ) . attr ( "test:attrib" ) , undefined , "Retrieving a non-existent attribute on a table with a colon does not throw an error." ) ;
147
+ equal ( jQuery ( "#table" ) . attr ( "test:attrib" ) , null , "Retrieving a non-existent attribute on a table with a colon does not throw an error." ) ;
148
148
equal ( jQuery ( "#table" ) . attr ( "test:attrib" , "foobar" ) . attr ( "test:attrib" ) , "foobar" , "Setting an attribute on a table with a colon does not throw an error." ) ;
149
149
150
150
$form = jQuery ( "<form class='something'></form>" ) . appendTo ( "#qunit-fixture" ) ;
@@ -153,12 +153,12 @@ test( "attr(String)", function() {
153
153
$a = jQuery ( "<a href='#' onclick='something()'>Click</a>" ) . appendTo ( "#qunit-fixture" ) ;
154
154
equal ( $a . attr ( "onclick" ) , "something()" , "Retrieve ^on attribute without anonymous function wrapper." ) ;
155
155
156
- ok ( jQuery ( "<div/>" ) . attr ( "doesntexist" ) === undefined , "Make sure undefined is returned when no attribute is found." ) ;
157
- ok ( jQuery ( "<div/>" ) . attr ( "title" ) === undefined , "Make sure undefined is returned when no attribute is found." ) ;
156
+ ok ( jQuery ( "<div/>" ) . attr ( "doesntexist" ) === null , "Make sure null is returned when no attribute is found." ) ;
157
+ ok ( jQuery ( "<div/>" ) . attr ( "title" ) === null , "Make sure null is returned when no attribute is found." ) ;
158
158
equal ( jQuery ( "<div/>" ) . attr ( "title" , "something" ) . attr ( "title" ) , "something" , "Set the title attribute." ) ;
159
159
ok ( jQuery ( ) . attr ( "doesntexist" ) === undefined , "Make sure undefined is returned when no element is there." ) ;
160
- equal ( jQuery ( "<div/>" ) . attr ( "value" ) , undefined , "An unset value on a div returns undefined ." ) ;
161
- strictEqual ( jQuery ( "<select><option value='property'></option></select>" ) . attr ( "value" ) , undefined , "An unset value on a select returns undefined ." ) ;
160
+ equal ( jQuery ( "<div/>" ) . attr ( "value" ) , null , "An unset value on a div returns null ." ) ;
161
+ strictEqual ( jQuery ( "<select><option value='property'></option></select>" ) . attr ( "value" ) , null , "An unset value on a select returns null ." ) ;
162
162
163
163
$form = jQuery ( "#form" ) . attr ( "enctype" , "multipart/form-data" ) ;
164
164
equal ( $form . prop ( "enctype" ) , "multipart/form-data" , "Set the enctype of a form (encoding in IE6/7 #6743)" ) ;
@@ -280,7 +280,7 @@ test( "attr(String, Object)", function() {
280
280
jQuery ( "#name" ) . attr ( "name" , "something" ) ;
281
281
equal ( jQuery ( "#name" ) . attr ( "name" ) , "something" , "Set name attribute" ) ;
282
282
jQuery ( "#name" ) . attr ( "name" , null ) ;
283
- equal ( jQuery ( "#name" ) . attr ( "name" ) , undefined , "Remove name attribute" ) ;
283
+ equal ( jQuery ( "#name" ) . attr ( "name" ) , null , "Remove name attribute" ) ;
284
284
285
285
$input = jQuery ( "<input>" , {
286
286
name : "something" ,
@@ -301,17 +301,17 @@ test( "attr(String, Object)", function() {
301
301
$input . prop ( "checked" , true ) . prop ( "checked" , false ) . attr ( "checked" , true ) ;
302
302
equal ( $input . attr ( "checked" ) , "checked" , "Set checked (verified by .attr)" ) ;
303
303
$input . prop ( "checked" , false ) . prop ( "checked" , true ) . attr ( "checked" , false ) ;
304
- equal ( $input . attr ( "checked" ) , undefined , "Remove checked (verified by .attr)" ) ;
304
+ equal ( $input . attr ( "checked" ) , null , "Remove checked (verified by .attr)" ) ;
305
305
306
306
$input = jQuery ( "#text1" ) . prop ( "readOnly" , true ) . prop ( "readOnly" , false ) . attr ( "readonly" , true ) ;
307
307
equal ( $input . attr ( "readonly" ) , "readonly" , "Set readonly (verified by .attr)" ) ;
308
308
$input . prop ( "readOnly" , false ) . prop ( "readOnly" , true ) . attr ( "readonly" , false ) ;
309
- equal ( $input . attr ( "readonly" ) , undefined , "Remove readonly (verified by .attr)" ) ;
309
+ equal ( $input . attr ( "readonly" ) , null , "Remove readonly (verified by .attr)" ) ;
310
310
311
311
$input = jQuery ( "#check2" ) . attr ( "checked" , true ) . attr ( "checked" , false ) . prop ( "checked" , true ) ;
312
312
equal ( $input [ 0 ] . checked , true , "Set checked property (verified by native property)" ) ;
313
313
equal ( $input . prop ( "checked" ) , true , "Set checked property (verified by .prop)" ) ;
314
- equal ( $input . attr ( "checked" ) , undefined , "Setting checked property doesn't affect checked attribute" ) ;
314
+ equal ( $input . attr ( "checked" ) , null , "Setting checked property doesn't affect checked attribute" ) ;
315
315
$input . attr ( "checked" , false ) . attr ( "checked" , true ) . prop ( "checked" , false ) ;
316
316
equal ( $input [ 0 ] . checked , false , "Clear checked property (verified by native property)" ) ;
317
317
equal ( $input . prop ( "checked" ) , false , "Clear checked property (verified by .prop)" ) ;
@@ -343,13 +343,13 @@ test( "attr(String, Object)", function() {
343
343
"required" : true
344
344
} ) ;
345
345
equal ( $text . attr ( "autofocus" ) , "autofocus" , "Reading autofocus attribute yields 'autofocus'" ) ;
346
- equal ( $text . attr ( "autofocus" , false ) . attr ( "autofocus" ) , undefined , "Setting autofocus to false removes it" ) ;
346
+ equal ( $text . attr ( "autofocus" , false ) . attr ( "autofocus" ) , null , "Setting autofocus to false removes it" ) ;
347
347
equal ( $text . attr ( "required" ) , "required" , "Reading required attribute yields 'required'" ) ;
348
- equal ( $text . attr ( "required" , false ) . attr ( "required" ) , undefined , "Setting required attribute to false removes it" ) ;
348
+ equal ( $text . attr ( "required" , false ) . attr ( "required" ) , null , "Setting required attribute to false removes it" ) ;
349
349
350
350
$details = jQuery ( "<details open></details>" ) . appendTo ( "#qunit-fixture" ) ;
351
351
equal ( $details . attr ( "open" ) , "open" , "open attribute presence indicates true" ) ;
352
- equal ( $details . attr ( "open" , false ) . attr ( "open" ) , undefined , "Setting open attribute to false removes it" ) ;
352
+ equal ( $details . attr ( "open" , false ) . attr ( "open" ) , null , "Setting open attribute to false removes it" ) ;
353
353
354
354
$text . attr ( "data-something" , true ) ;
355
355
equal ( $text . attr ( "data-something" ) , "true" , "Set data attributes" ) ;
@@ -371,13 +371,13 @@ test( "attr(String, Object)", function() {
371
371
jQuery . each ( [ commentNode , textNode , attributeNode ] , function ( i , elem ) {
372
372
var $elem = jQuery ( elem ) ;
373
373
$elem . attr ( "nonexisting" , "foo" ) ;
374
- strictEqual ( $elem . attr ( "nonexisting" ) , undefined , "attr(name, value) works correctly on comment and text nodes (bug #7500)." ) ;
374
+ strictEqual ( $elem . attr ( "nonexisting" ) , null , "attr(name, value) works correctly on comment and text nodes (bug #7500)." ) ;
375
375
} ) ;
376
376
377
377
jQuery . each ( [ window , document , obj , "#firstp" ] , function ( i , elem ) {
378
378
var oldVal = elem . nonexisting ,
379
379
$elem = jQuery ( elem ) ;
380
- strictEqual ( $elem . attr ( "nonexisting" ) , undefined , "attr works correctly for non existing attributes (bug #7500)." ) ;
380
+ strictEqual ( $elem . attr ( "nonexisting" ) , null , "attr works correctly for non existing attributes (bug #7500)." ) ;
381
381
equal ( $elem . attr ( "nonexisting" , "foo" ) . attr ( "nonexisting" ) , "foo" , "attr falls back to prop on unsupported arguments" ) ;
382
382
elem . nonexisting = oldVal ;
383
383
} ) ;
@@ -394,7 +394,7 @@ test( "attr(String, Object)", function() {
394
394
table . attr ( "cellspacing" , "2" ) ;
395
395
equal ( table [ 0 ] [ "cellSpacing" ] , "2" , "Check cellspacing is correctly set" ) ;
396
396
397
- equal ( jQuery ( "#area1" ) . attr ( "value" ) , undefined , "Value attribute is distinct from value property." ) ;
397
+ equal ( jQuery ( "#area1" ) . attr ( "value" ) , null , "Value attribute is distinct from value property." ) ;
398
398
399
399
// for #1070
400
400
jQuery ( "#name" ) . attr ( "someAttr" , "0" ) ;
@@ -468,7 +468,7 @@ test( "attr(String, Object)", function() {
468
468
jQuery ( "#name" ) . attr ( "maxlength" , "5" ) . removeAttr ( "nonexisting" ) ;
469
469
equal ( typeof jQuery ( "#name" ) . attr ( "maxlength" , undefined ) , "object" , ".attr('attribute', undefined) is chainable (#5571)" ) ;
470
470
equal ( jQuery ( "#name" ) . attr ( "maxlength" , undefined ) . attr ( "maxlength" ) , "5" , ".attr('attribute', undefined) does not change value (#5571)" ) ;
471
- equal ( jQuery ( "#name" ) . attr ( "nonexisting" , undefined ) . attr ( "nonexisting" ) , undefined , ".attr('attribute', undefined) does not create attribute (#5571)" ) ;
471
+ equal ( jQuery ( "#name" ) . attr ( "nonexisting" , undefined ) . attr ( "nonexisting" ) , null , ".attr('attribute', undefined) does not create attribute (#5571)" ) ;
472
472
} ) ;
473
473
474
474
test ( "attr - extending the boolean attrHandle" , function ( ) {
@@ -504,23 +504,23 @@ test( "attr(String, Object) - Loaded via XML fragment", function() {
504
504
$frag . attr ( "test" , "some value" ) ;
505
505
equal ( $frag . attr ( "test" ) , "some value" , "set attribute" ) ;
506
506
$frag . attr ( "test" , null ) ;
507
- equal ( $frag . attr ( "test" ) , undefined , "remove attribute" ) ;
507
+ equal ( $frag . attr ( "test" ) , null , "remove attribute" ) ;
508
508
} ) ;
509
509
510
510
test ( "attr('tabindex')" , function ( ) {
511
511
expect ( 8 ) ;
512
512
513
513
// elements not natively tabbable
514
514
equal ( jQuery ( "#listWithTabIndex" ) . attr ( "tabindex" ) , "5" , "not natively tabbable, with tabindex set to 0" ) ;
515
- equal ( jQuery ( "#divWithNoTabIndex" ) . attr ( "tabindex" ) , undefined , "not natively tabbable, no tabindex set" ) ;
515
+ equal ( jQuery ( "#divWithNoTabIndex" ) . attr ( "tabindex" ) , null , "not natively tabbable, no tabindex set" ) ;
516
516
517
517
// anchor with href
518
- equal ( jQuery ( "#linkWithNoTabIndex" ) . attr ( "tabindex" ) , undefined , "anchor with href, no tabindex set" ) ;
518
+ equal ( jQuery ( "#linkWithNoTabIndex" ) . attr ( "tabindex" ) , null , "anchor with href, no tabindex set" ) ;
519
519
equal ( jQuery ( "#linkWithTabIndex" ) . attr ( "tabindex" ) , "2" , "anchor with href, tabindex set to 2" ) ;
520
520
equal ( jQuery ( "#linkWithNegativeTabIndex" ) . attr ( "tabindex" ) , "-1" , "anchor with href, tabindex set to -1" ) ;
521
521
522
522
// anchor without href
523
- equal ( jQuery ( "#linkWithNoHrefWithNoTabIndex" ) . attr ( "tabindex" ) , undefined , "anchor without href, no tabindex set" ) ;
523
+ equal ( jQuery ( "#linkWithNoHrefWithNoTabIndex" ) . attr ( "tabindex" ) , null , "anchor without href, no tabindex set" ) ;
524
524
equal ( jQuery ( "#linkWithNoHrefWithTabIndex" ) . attr ( "tabindex" ) , "1" , "anchor without href, tabindex set to 2" ) ;
525
525
equal ( jQuery ( "#linkWithNoHrefWithNegativeTabIndex" ) . attr ( "tabindex" ) , "-1" , "anchor without href, no tabindex set" ) ;
526
526
} ) ;
@@ -529,7 +529,7 @@ test( "attr('tabindex', value)", function() {
529
529
expect ( 9 ) ;
530
530
531
531
var element = jQuery ( "#divWithNoTabIndex" ) ;
532
- equal ( element . attr ( "tabindex" ) , undefined , "start with no tabindex" ) ;
532
+ equal ( element . attr ( "tabindex" ) , null , "start with no tabindex" ) ;
533
533
534
534
// set a positive string
535
535
element . attr ( "tabindex" , "1" ) ;
@@ -566,10 +566,10 @@ test( "removeAttr(String)", function() {
566
566
expect ( 12 ) ;
567
567
var $first ;
568
568
569
- equal ( jQuery ( "#mark" ) . removeAttr ( "class" ) . attr ( "class" ) , undefined , "remove class" ) ;
570
- equal ( jQuery ( "#form" ) . removeAttr ( "id" ) . attr ( "id" ) , undefined , "Remove id" ) ;
571
- equal ( jQuery ( "#foo" ) . attr ( "style" , "position:absolute;" ) . removeAttr ( "style" ) . attr ( "style" ) , undefined , "Check removing style attribute" ) ;
572
- equal ( jQuery ( "#form" ) . attr ( "style" , "position:absolute;" ) . removeAttr ( "style" ) . attr ( "style" ) , undefined , "Check removing style attribute on a form" ) ;
569
+ equal ( jQuery ( "#mark" ) . removeAttr ( "class" ) . attr ( "class" ) , null , "remove class" ) ;
570
+ equal ( jQuery ( "#form" ) . removeAttr ( "id" ) . attr ( "id" ) , null , "Remove id" ) ;
571
+ equal ( jQuery ( "#foo" ) . attr ( "style" , "position:absolute;" ) . removeAttr ( "style" ) . attr ( "style" ) , null , "Check removing style attribute" ) ;
572
+ equal ( jQuery ( "#form" ) . attr ( "style" , "position:absolute;" ) . removeAttr ( "style" ) . attr ( "style" ) , null , "Check removing style attribute on a form" ) ;
573
573
equal ( jQuery ( "<div style='position: absolute'></div>" ) . appendTo ( "#foo" ) . removeAttr ( "style" ) . prop ( "style" ) . cssText , "" , "Check removing style attribute (#9699 Webkit)" ) ;
574
574
equal ( jQuery ( "#fx-test-group" ) . attr ( "height" , "3px" ) . removeAttr ( "height" ) . get ( 0 ) . style . height , "1px" , "Removing height attribute has no effect on height set with style attribute" ) ;
575
575
@@ -583,15 +583,15 @@ test( "removeAttr(String)", function() {
583
583
584
584
try {
585
585
$first = jQuery ( "#first" ) . attr ( "contenteditable" , "true" ) . removeAttr ( "contenteditable" ) ;
586
- equal ( $first . attr ( "contenteditable" ) , undefined , "Remove the contenteditable attribute" ) ;
586
+ equal ( $first . attr ( "contenteditable" ) , null , "Remove the contenteditable attribute" ) ;
587
587
} catch ( e ) {
588
588
ok ( false , "Removing contenteditable threw an error (#10429)" ) ;
589
589
}
590
590
591
591
$first = jQuery ( "<div Case='mixed'></div>" ) ;
592
592
equal ( $first . attr ( "Case" ) , "mixed" , "case of attribute doesn't matter" ) ;
593
593
$first . removeAttr ( "Case" ) ;
594
- equal ( $first . attr ( "Case" ) , undefined , "mixed-case attribute was removed" ) ;
594
+ equal ( $first . attr ( "Case" ) , null , "mixed-case attribute was removed" ) ;
595
595
} ) ;
596
596
597
597
test ( "removeAttr(String) in XML" , function ( ) {
@@ -603,14 +603,14 @@ test( "removeAttr(String) in XML", function() {
603
603
iwt . removeAttr ( "Normal" ) ;
604
604
equal ( iwt . attr ( "normal" ) , "ab" , "Should still be there" ) ;
605
605
iwt . removeAttr ( "normal" ) ;
606
- equal ( iwt . attr ( "normal" ) , undefined , "Removed" ) ;
606
+ equal ( iwt . attr ( "normal" ) , null , "Removed" ) ;
607
607
608
608
equal ( iwt . attr ( "mixedCase" ) , "yes" , "Check initial value" ) ;
609
- equal ( iwt . attr ( "mixedcase" ) , undefined , "toLowerCase not work good" ) ;
609
+ equal ( iwt . attr ( "mixedcase" ) , null , "toLowerCase not work good" ) ;
610
610
iwt . removeAttr ( "mixedcase" ) ;
611
611
equal ( iwt . attr ( "mixedCase" ) , "yes" , "Should still be there" ) ;
612
612
iwt . removeAttr ( "mixedCase" ) ;
613
- equal ( iwt . attr ( "mixedCase" ) , undefined , "Removed" ) ;
613
+ equal ( iwt . attr ( "mixedCase" ) , null , "Removed" ) ;
614
614
} ) ;
615
615
616
616
test ( "removeAttr(Multi String, variable space width)" , function ( ) {
@@ -631,7 +631,7 @@ test( "removeAttr(Multi String, variable space width)", function() {
631
631
div . removeAttr ( "id alt title rel " ) ;
632
632
633
633
jQuery . each ( tests , function ( key ) {
634
- equal ( div . attr ( key ) , undefined , "Attribute `" + key + "` was removed" ) ;
634
+ equal ( div . attr ( key ) , null , "Attribute `" + key + "` was removed" ) ;
635
635
} ) ;
636
636
} ) ;
637
637
@@ -1162,7 +1162,7 @@ var testRemoveClass = function(valueObj) {
1162
1162
1163
1163
1164
1164
jQuery ( div ) . removeClass ( valueObj ( "foo" ) ) ;
1165
- strictEqual ( jQuery ( div ) . attr ( "class" ) , undefined , "removeClass doesn't create a class attribute" ) ;
1165
+ strictEqual ( jQuery ( div ) . attr ( "class" ) , null , "removeClass doesn't create a class attribute" ) ;
1166
1166
1167
1167
div . className = " test foo " ;
1168
1168
0 commit comments