Fixed some bugs relating to the setter arg change in val and html. Also optimized the code in val a bit.
This commit is contained in:
parent
2526e29353
commit
4681216c4b
|
@ -195,30 +195,25 @@ jQuery.fn.extend({
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Typecast once if the value is a number
|
var isFunction = jQuery.isFunction(value);
|
||||||
if ( typeof value === "number" ) {
|
|
||||||
value += "";
|
|
||||||
}
|
|
||||||
|
|
||||||
var val = value;
|
|
||||||
|
|
||||||
return this.each(function(i) {
|
return this.each(function(i) {
|
||||||
var self = jQuery(this);
|
var self = jQuery(this), val = value;
|
||||||
|
|
||||||
if ( jQuery.isFunction(value) ) {
|
|
||||||
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" ) {
|
|
||||||
val += "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( this.nodeType !== 1 ) {
|
if ( this.nodeType !== 1 ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( isFunction ) {
|
||||||
|
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" ) {
|
||||||
|
val += "";
|
||||||
|
}
|
||||||
|
|
||||||
if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) {
|
if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) {
|
||||||
this.checked = jQuery.inArray( self.val(), val ) >= 0;
|
this.checked = jQuery.inArray( self.val(), val ) >= 0;
|
||||||
|
|
||||||
|
@ -226,7 +221,7 @@ jQuery.fn.extend({
|
||||||
var values = jQuery.makeArray(val);
|
var values = jQuery.makeArray(val);
|
||||||
|
|
||||||
jQuery( "option", this ).each(function() {
|
jQuery( "option", this ).each(function() {
|
||||||
this.selected = jQuery.inArray( self.val(), values ) >= 0;
|
this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
if ( !values.length ) {
|
if ( !values.length ) {
|
||||||
|
|
|
@ -173,7 +173,7 @@ jQuery.fn.extend({
|
||||||
|
|
||||||
html: function( value ) {
|
html: function( value ) {
|
||||||
if ( value === undefined ) {
|
if ( value === undefined ) {
|
||||||
return this[0] ?
|
return this[0] && this[0].nodeType === 1 ?
|
||||||
this[0].innerHTML.replace(rinlinejQuery, "") :
|
this[0].innerHTML.replace(rinlinejQuery, "") :
|
||||||
null;
|
null;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue