jquery core: Closes #3255. The div used in jQuery.clean is emptied in the end. Cleaning the parentNode's properties of the elements.
This commit is contained in:
parent
4b25b147ab
commit
0e3e470edc
|
@ -909,13 +909,14 @@ jQuery.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
clean: function( elems, context, fragment ) {
|
clean: function( elems, context, fragment ) {
|
||||||
var ret = [], scripts = [];
|
|
||||||
context = context || document;
|
context = context || document;
|
||||||
|
|
||||||
// !context.createElement fails in IE with an error but returns typeof 'object'
|
// !context.createElement fails in IE with an error but returns typeof 'object'
|
||||||
if ( typeof context.createElement === "undefined" )
|
if ( typeof context.createElement === "undefined" )
|
||||||
context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
|
context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
|
||||||
|
|
||||||
|
var ret = [], scripts = [], div = context.createElement("div");
|
||||||
|
|
||||||
jQuery.each(elems, function(i, elem){
|
jQuery.each(elems, function(i, elem){
|
||||||
if ( typeof elem === "number" )
|
if ( typeof elem === "number" )
|
||||||
elem += '';
|
elem += '';
|
||||||
|
@ -933,7 +934,7 @@ jQuery.extend({
|
||||||
});
|
});
|
||||||
|
|
||||||
// Trim whitespace, otherwise indexOf won't work as expected
|
// Trim whitespace, otherwise indexOf won't work as expected
|
||||||
var tags = jQuery.trim( elem ).toLowerCase(), div = context.createElement("div");
|
var tags = jQuery.trim( elem ).toLowerCase();
|
||||||
|
|
||||||
var wrap =
|
var wrap =
|
||||||
// option or optgroup
|
// option or optgroup
|
||||||
|
@ -1009,6 +1010,9 @@ jQuery.extend({
|
||||||
ret = jQuery.merge( ret, elem );
|
ret = jQuery.merge( ret, elem );
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Clean up
|
||||||
|
div.innerHTML = "";
|
||||||
|
|
||||||
if ( fragment ) {
|
if ( fragment ) {
|
||||||
for ( var i = 0; ret[i]; i++ ) {
|
for ( var i = 0; ret[i]; i++ ) {
|
||||||
|
|
|
@ -451,7 +451,7 @@ test("attr(Hash)", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("attr(String, Object)", function() {
|
test("attr(String, Object)", function() {
|
||||||
expect(17);
|
expect(19);
|
||||||
var div = jQuery("div").attr("foo", "bar");
|
var div = jQuery("div").attr("foo", "bar");
|
||||||
fail = false;
|
fail = false;
|
||||||
for ( var i = 0; i < div.size(); i++ ) {
|
for ( var i = 0; i < div.size(); i++ ) {
|
||||||
|
@ -515,6 +515,16 @@ test("attr(String, Object)", function() {
|
||||||
}
|
}
|
||||||
ok( thrown, "Exception thrown when trying to change type property" );
|
ok( thrown, "Exception thrown when trying to change type property" );
|
||||||
equals( "checkbox", jQuery(check).attr('type'), "Verify that you can change the type of an input element that isn't in the DOM" );
|
equals( "checkbox", jQuery(check).attr('type'), "Verify that you can change the type of an input element that isn't in the DOM" );
|
||||||
|
|
||||||
|
var check = jQuery("<input />");
|
||||||
|
var thrown = true;
|
||||||
|
try {
|
||||||
|
check.attr('type','checkbox');
|
||||||
|
} catch(e) {
|
||||||
|
thrown = false;
|
||||||
|
}
|
||||||
|
ok( thrown, "Exception thrown when trying to change type property" );
|
||||||
|
equals( "checkbox", check.attr('type'), "Verify that you can change the type of an input element that isn't in the DOM" );
|
||||||
});
|
});
|
||||||
|
|
||||||
if ( !isLocal ) {
|
if ( !isLocal ) {
|
||||||
|
@ -1139,6 +1149,8 @@ test("is(String)", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("jQuery.merge()", function() {
|
test("jQuery.merge()", function() {
|
||||||
|
expect(6);
|
||||||
|
|
||||||
var parse = jQuery.merge;
|
var parse = jQuery.merge;
|
||||||
|
|
||||||
same( parse([],[]), [], "Empty arrays" );
|
same( parse([],[]), [], "Empty arrays" );
|
||||||
|
|
Loading…
Reference in a new issue