git.asbjorn.biz
/
jquery.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
83a044f
)
If .attr() is run on no elements undefined should be returned (as should be the case...
author
jeresig
<jeresig@gmail.com>
Sat, 13 Feb 2010 07:23:38 +0000
(
02:23
-0500)
committer
jeresig
<jeresig@gmail.com>
Sat, 13 Feb 2010 07:23:38 +0000
(
02:23
-0500)
src/core.js
patch
|
blob
|
history
test/unit/attributes.js
patch
|
blob
|
history
diff --git
a/src/core.js
b/src/core.js
index
9fa311d
..
ba5d7f5
100644
(file)
--- a/
src/core.js
+++ b/
src/core.js
@@
-799,7
+799,7
@@
function access( elems, key, value, exec, fn, pass ) {
}
// Getting an attribute
}
// Getting an attribute
- return length ? fn( elems[0], key ) : null;
+ return length ? fn( elems[0], key ) : undefined;
}
function now() {
}
function now() {
diff --git
a/test/unit/attributes.js
b/test/unit/attributes.js
index
234d586
..
c5700ad
100644
(file)
--- a/
test/unit/attributes.js
+++ b/
test/unit/attributes.js
@@
-4,7
+4,7
@@
var bareObj = function(value) { return value; };
var functionReturningObj = function(value) { return (function() { return value; }); };
test("attr(String)", function() {
var functionReturningObj = function(value) { return (function() { return value; }); };
test("attr(String)", function() {
- expect(28);
+ expect(30);
// This one sometimes fails randomly ?!
equals( jQuery('#text1').attr('value'), "Test", 'Check for value attribute' );
// This one sometimes fails randomly ?!
equals( jQuery('#text1').attr('value'), "Test", 'Check for value attribute' );
@@
-61,6
+61,9
@@
test("attr(String)", function() {
select.appendChild( optgroup );
equals( jQuery(option).attr("selected"), true, "Make sure that a single option is selected, even when in an optgroup." );
select.appendChild( optgroup );
equals( jQuery(option).attr("selected"), true, "Make sure that a single option is selected, even when in an optgroup." );
+
+ ok( jQuery("<div/>").attr("doesntexist") === undefined, "Make sure undefined is returned when no attribute is found." );
+ ok( jQuery().attr("doesntexist") === undefined, "Make sure undefined is returned when no element is there." );
});
if ( !isLocal ) {
});
if ( !isLocal ) {