git.asbjorn.biz
/
jquery.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update number of expected assertions in attribute tests
[jquery.git]
/
src
/
attributes.js
diff --git
a/src/attributes.js
b/src/attributes.js
index
a76695b
..
147c353
100644
(file)
--- a/
src/attributes.js
+++ b/
src/attributes.js
@@
-136,7
+136,7
@@
jQuery.fn.extend({
},
val: function( value ) {
},
val: function( value ) {
- if ( value === undefined ) {
+ if ( !arguments.length ) {
var elem = this[0];
if ( elem ) {
var elem = this[0];
if ( elem ) {
@@
-164,8
+164,9
@@
jQuery.fn.extend({
var option = options[ i ];
// Don't return options that are disabled or in a disabled optgroup
var option = options[ i ];
// Don't return options that are disabled or in a disabled optgroup
- if ( option.selected && !option.disabled &&
+ if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
(!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
(!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
+
// Get the specific value for the option
value = jQuery(option).val();
// Get the specific value for the option
value = jQuery(option).val();
@@
-209,10
+210,15
@@
jQuery.fn.extend({
val = value.call(this, i, self.val());
}
val = value.call(this, i, self.val());
}
- // Typecast each time if the value is a Function and the appended
- // value is therefore different each time.
- if ( typeof val === "number" ) {
+ // Treat null/undefined as ""; convert numbers to string
+ if ( val == null ) {
+ val = "";
+ } else if ( typeof val === "number" ) {
val += "";
val += "";
+ } else if ( jQuery.isArray(val) ) {
+ val = jQuery.map(val, function (value) {
+ return value == null ? "" : value + "";
+ });
}
if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) {
}
if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) {
@@
-293,7
+299,14
@@
jQuery.extend({
jQuery.error( "type property can't be changed" );
}
jQuery.error( "type property can't be changed" );
}
- elem[ name ] = value;
+ if ( value === null ) {
+ if ( elem.nodeType === 1 ) {
+ elem.removeAttribute( name );
+ }
+
+ } else {
+ elem[ name ] = value;
+ }
}
// browsers index elements by id/name on forms, give priority to attributes.
}
// browsers index elements by id/name on forms, give priority to attributes.
@@
-331,7
+344,7
@@
jQuery.extend({
// Ensure that missing attributes return undefined
// Blackberry 4.7 returns "" from getAttribute #6938
// Ensure that missing attributes return undefined
// Blackberry 4.7 returns "" from getAttribute #6938
- if ( !elem.attributes[ name ] && !elem.hasAttribute( name ) ) {
+ if ( !elem.attributes[ name ] && (elem.hasAttribute && !elem.hasAttribute( name )) ) {
return undefined;
}
return undefined;
}