Ticket #2930: normalized-attr.diff
| File normalized-attr.diff, 2.8 kB (added by flesler, 8 months ago) |
|---|
-
src/core.js
1057 1057 elem.parentNode.selectedIndex; 1058 1058 1059 1059 // If applicable, access the attribute via the DOM 0 way 1060 if ( n otxml && !special && name in elem) {1060 if ( name in elem && notxml && !special ) { 1061 1061 if ( set ){ 1062 1062 // We can't allow the type property to be changed (since it causes problems in IE) 1063 1063 if ( name == "type" && jQuery.nodeName( elem, "input" ) && elem.parentNode ) … … 1080 1080 // convert the value to a string (all browsers do this but IE) see #1070 1081 1081 elem.setAttribute( name, "" + value ); 1082 1082 1083 if ( msie && special && notxml ) 1084 return elem.getAttribute( name, 2 ); 1083 var attr = msie && notxml && special 1084 // Some attributes require a special call on IE 1085 ? elem.getAttribute( name, 2 ) 1086 : elem.getAttribute( name ); 1085 1087 1086 return elem.getAttribute( name ); 1088 // Non-existent attributes return null, we normalize to undefined 1089 return attr === null ? undefined : attr; 1087 1090 1088 1091 } 1089 1092 -
test/unit/core.js
320 320 }); 321 321 322 322 test("attr(String)", function() { 323 expect(2 0);323 expect(26); 324 324 equals( $('#text1').attr('value'), "Test", 'Check for value attribute' ); 325 325 equals( $('#text1').attr('value', "Test2").attr('defaultValue'), "Test", 'Check for defaultValue attribute' ); 326 326 equals( $('#text1').attr('type'), "text", 'Check for type attribute' ); … … 343 343 344 344 $('<a id="tAnchor5"></a>').attr('href', '#5').appendTo('#main'); // using innerHTML in IE causes href attribute to be serialized to the full path 345 345 equals( $('#tAnchor5').attr('href'), "#5", 'Check for non-absolute href (an anchor)' ); 346 347 // Enabled since [5574] 348 var body = document.body, $body = $(body); 349 350 ok( $body.attr('foo') === undefined, 'Make sure that a non existent attribute returns undefined' ); 351 ok( $body.attr('nextSibling') === null, 'Make sure a null expando returns null' ); 352 353 body.setAttribute('foo', 'baz'); 354 equals( $body.attr('foo'), 'baz', 'Make sure the dom attribute is retrieved when no expando is found' ); 355 356 body.foo = 'bar'; 357 equals( $body.attr('foo'), 'bar', 'Make sure the expando is preferred over the dom attribute' ); 358 359 $body.attr('foo','cool'); 360 equals( $body.attr('foo'), 'cool', 'Make sure that setting works well when both expando and dom attribute are available' ); 361 362 body.foo = undefined; 363 ok( $body.attr('foo') === undefined, 'Make sure the expando is preferred over the dom attribute, even if undefined' ); 364 365 body.removeAttribute('foo'); // Cleanup 346 366 }); 347 367 348 368 if ( !isLocal ) {
