Skip to content
Permalink
Browse files

Fixed some bugs relating to the setter arg change in val and html. Al…

…so optimized the code in val a bit.
  • Loading branch information
jeresig committed Jan 7, 2010
1 parent 2526e29 commit 4681216c4bdf25b6b146b3f952917f46079c6ef7
Showing with 13 additions and 18 deletions.
  1. +12 −17 src/attributes.js
  2. +1 −1 src/manipulation.js
@@ -195,28 +195,23 @@ jQuery.fn.extend({
return undefined;
}

// Typecast once if the value is a number
if ( typeof value === "number" ) {
value += "";
}

var val = value;
var isFunction = jQuery.isFunction(value);

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());
if ( this.nodeType !== 1 ) {
return;
}

// Typecast each time if the value is a Function and the appended
// value is therefore different each time.
if ( typeof val === "number" ) {
val += "";
}
if ( isFunction ) {
val = value.call(this, i, self.val());
}

if ( this.nodeType !== 1 ) {
return;
// 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 ) ) {
@@ -226,7 +221,7 @@ jQuery.fn.extend({
var values = jQuery.makeArray(val);

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 ) {
@@ -173,7 +173,7 @@ jQuery.fn.extend({

html: function( value ) {
if ( value === undefined ) {
return this[0] ?
return this[0] && this[0].nodeType === 1 ?
this[0].innerHTML.replace(rinlinejQuery, "") :
null;

0 comments on commit 4681216

Please sign in to comment.
You can’t perform that action at this time.