mirror of
https://github.com/jquery/jquery.git
synced 2024-10-05 11:34:18 +00:00
Fix #12336. Ensure oldIE really does .empty() selects.
This commit is contained in:
parent
b45c775ca9
commit
bbdf957e98
@ -192,6 +192,12 @@ jQuery.fn.extend({
|
|||||||
while ( elem.firstChild ) {
|
while ( elem.firstChild ) {
|
||||||
elem.removeChild( elem.firstChild );
|
elem.removeChild( elem.firstChild );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If this is a select, ensure that it displays empty (#12336)
|
||||||
|
// Support: IE<9
|
||||||
|
if ( elem.options && jQuery.nodeName( elem, "select" ) ) {
|
||||||
|
elem.options.length = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
@ -1829,7 +1829,7 @@ test( "detach() event cleaning ", 1, function() {
|
|||||||
|
|
||||||
test("empty()", function() {
|
test("empty()", function() {
|
||||||
|
|
||||||
expect( 3 );
|
expect( 6 );
|
||||||
|
|
||||||
equal( jQuery("#ap").children().empty().text().length, 0, "Check text is removed" );
|
equal( jQuery("#ap").children().empty().text().length, 0, "Check text is removed" );
|
||||||
equal( jQuery("#ap").children().length, 4, "Check elements are not removed" );
|
equal( jQuery("#ap").children().length, 4, "Check elements are not removed" );
|
||||||
@ -1838,7 +1838,13 @@ test("empty()", function() {
|
|||||||
var j = jQuery("#nonnodes").contents();
|
var j = jQuery("#nonnodes").contents();
|
||||||
j.empty();
|
j.empty();
|
||||||
equal( j.html(), "", "Check node,textnode,comment empty works" );
|
equal( j.html(), "", "Check node,textnode,comment empty works" );
|
||||||
});
|
|
||||||
|
// Ensure oldIE empties selects (#12336)
|
||||||
|
notEqual( $("#select1").find("option").length, 0, "Have some initial options" );
|
||||||
|
$("#select1").empty();
|
||||||
|
equal( $("#select1").find("option").length, 0, "No more option elements found" );
|
||||||
|
equal( $("#select1")[0].options.length, 0, "options.length cleared as well" );
|
||||||
|
});
|
||||||
|
|
||||||
test( "jQuery.cleanData", function() {
|
test( "jQuery.cleanData", function() {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user