test runner: adding more tests for attr(). Related to [5574] and [5683].
This commit is contained in:
parent
cff5323a1d
commit
0e63c789e3
|
@ -320,7 +320,7 @@ test("index(Object)", function() {
|
|||
});
|
||||
|
||||
test("attr(String)", function() {
|
||||
expect(20);
|
||||
expect(26);
|
||||
equals( $('#text1').attr('value'), "Test", 'Check for value attribute' );
|
||||
equals( $('#text1').attr('value', "Test2").attr('defaultValue'), "Test", 'Check for defaultValue attribute' );
|
||||
equals( $('#text1').attr('type'), "text", 'Check for type attribute' );
|
||||
|
@ -343,6 +343,27 @@ test("attr(String)", function() {
|
|||
|
||||
$('<a id="tAnchor5"></a>').attr('href', '#5').appendTo('#main'); // using innerHTML in IE causes href attribute to be serialized to the full path
|
||||
equals( $('#tAnchor5').attr('href'), "#5", 'Check for non-absolute href (an anchor)' );
|
||||
|
||||
|
||||
// Related to [5574] and [5683]
|
||||
var body = document.body, $body = $(body);
|
||||
|
||||
ok( $body.attr('foo') === undefined, 'Make sure that a non existent attribute returns undefined' );
|
||||
ok( $body.attr('nextSibling') === null, 'Make sure a null expando returns null' );
|
||||
|
||||
body.setAttribute('foo', 'baz');
|
||||
equals( $body.attr('foo'), 'baz', 'Make sure the dom attribute is retrieved when no expando is found' );
|
||||
|
||||
body.foo = 'bar';
|
||||
equals( $body.attr('foo'), 'bar', 'Make sure the expando is preferred over the dom attribute' );
|
||||
|
||||
$body.attr('foo','cool');
|
||||
equals( $body.attr('foo'), 'cool', 'Make sure that setting works well when both expando and dom attribute are available' );
|
||||
|
||||
body.foo = undefined;
|
||||
ok( $body.attr('foo') === undefined, 'Make sure the expando is preferred over the dom attribute, even if undefined' );
|
||||
|
||||
body.removeAttribute('foo'); // Cleanup
|
||||
});
|
||||
|
||||
if ( !isLocal ) {
|
||||
|
|
Loading…
Reference in a new issue