mirror of
https://github.com/jquery/jquery.git
synced 2025-01-10 18:24:24 +00:00
Landing pull request 600. Remove jQuery.trim() to restore perf. Supplements #10773.
More Details: - https://github.com/jquery/jquery/pull/600 - http://bugs.jquery.com/ticket/10773
This commit is contained in:
parent
8bc60bab5d
commit
a8460d24e0
@ -355,21 +355,24 @@ jQuery.extend({
|
|||||||
var propName, attrNames, name, l,
|
var propName, attrNames, name, l,
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
if ( value && typeof value === "string" && elem.nodeType === 1 ) {
|
if ( value && elem.nodeType === 1 ) {
|
||||||
attrNames = jQuery.trim( value ).toLowerCase().split( " " );
|
attrNames = value.toLowerCase().split( rspace );
|
||||||
l = attrNames.length;
|
l = attrNames.length;
|
||||||
|
|
||||||
for ( ; i < l; i++ ) {
|
for ( ; i < l; i++ ) {
|
||||||
name = attrNames[ i ];
|
name = attrNames[ i ];
|
||||||
propName = jQuery.propFix[ name ] || name;
|
|
||||||
|
|
||||||
// See #9699 for explanation of this approach (setting first, then removal)
|
if ( name ) {
|
||||||
jQuery.attr( elem, name, "" );
|
propName = jQuery.propFix[ name ] || name;
|
||||||
elem.removeAttribute( getSetAttribute ? name : propName );
|
|
||||||
|
|
||||||
// Set corresponding property to false for boolean attributes
|
// See #9699 for explanation of this approach (setting first, then removal)
|
||||||
if ( rboolean.test( name ) && propName in elem ) {
|
jQuery.attr( elem, name, "" );
|
||||||
elem[ propName ] = false;
|
elem.removeAttribute( getSetAttribute ? name : propName );
|
||||||
|
|
||||||
|
// Set corresponding property to false for boolean attributes
|
||||||
|
if ( rboolean.test( name ) && propName in elem ) {
|
||||||
|
elem[ propName ] = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -481,20 +481,7 @@ test("removeAttr(String)", function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test("removeAttr, #", function() {
|
test("removeAttr(Multi String, variable space width)", function() {
|
||||||
|
|
||||||
var div = jQuery("<div />");
|
|
||||||
|
|
||||||
ok( div.removeAttr( "" ), "empty string" );
|
|
||||||
ok( div.removeAttr(), "nothing" );
|
|
||||||
ok( div.removeAttr( false ), "false" );
|
|
||||||
ok( div.removeAttr( true ), "true" );
|
|
||||||
ok( div.removeAttr({ }), "object" );
|
|
||||||
ok( div.removeAttr( function(){} ), "function" );
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
test("removeAttr(Multi String)", function() {
|
|
||||||
expect(8);
|
expect(8);
|
||||||
|
|
||||||
var div = jQuery("<div id='a' alt='b' title='c' rel='d'></div>"),
|
var div = jQuery("<div id='a' alt='b' title='c' rel='d'></div>"),
|
||||||
@ -509,7 +496,7 @@ test("removeAttr(Multi String)", function() {
|
|||||||
equal( div.attr(key), val, "Attribute `" + key + "` exists, and has a value of `" + val + "`" );
|
equal( div.attr(key), val, "Attribute `" + key + "` exists, and has a value of `" + val + "`" );
|
||||||
});
|
});
|
||||||
|
|
||||||
div.removeAttr( "id alt title rel " );
|
div.removeAttr( "id alt title rel " );
|
||||||
|
|
||||||
jQuery.each( tests, function( key, val ) {
|
jQuery.each( tests, function( key, val ) {
|
||||||
equal( div.attr(key), undefined, "Attribute `" + key + "` was removed" );
|
equal( div.attr(key), undefined, "Attribute `" + key + "` was removed" );
|
||||||
|
Loading…
Reference in New Issue
Block a user