Fix #2184 by using the jQuery.clean() function instead of a direct innerHTML assignment in the clone() function for IE.
This commit is contained in:
parent
e7fef859f1
commit
1faed11e3c
|
@ -303,11 +303,9 @@ jQuery.fn = jQuery.prototype = {
|
||||||
// as properties will not be copied (such as the
|
// as properties will not be copied (such as the
|
||||||
// the name attribute on an input).
|
// the name attribute on an input).
|
||||||
var clone = this.cloneNode(true),
|
var clone = this.cloneNode(true),
|
||||||
container = document.createElement("div"),
|
container = document.createElement("div");
|
||||||
container2 = document.createElement("div");
|
|
||||||
container.appendChild(clone);
|
container.appendChild(clone);
|
||||||
container2.innerHTML = container.innerHTML;
|
return jQuery.clean([container.innerHTML])[0];
|
||||||
return container2.firstChild;
|
|
||||||
} else
|
} else
|
||||||
return this.cloneNode(true);
|
return this.cloneNode(true);
|
||||||
});
|
});
|
||||||
|
|
|
@ -955,11 +955,23 @@ test("find(String)", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("clone()", function() {
|
test("clone()", function() {
|
||||||
expect(4);
|
expect(20);
|
||||||
ok( 'This is a normal link: Yahoo' == $('#en').text(), 'Assert text for #en' );
|
ok( 'This is a normal link: Yahoo' == $('#en').text(), 'Assert text for #en' );
|
||||||
var clone = $('#yahoo').clone();
|
var clone = $('#yahoo').clone();
|
||||||
ok( 'Try them out:Yahoo' == $('#first').append(clone).text(), 'Check for clone' );
|
ok( 'Try them out:Yahoo' == $('#first').append(clone).text(), 'Check for clone' );
|
||||||
ok( 'This is a normal link: Yahoo' == $('#en').text(), 'Reassert text for #en' );
|
ok( 'This is a normal link: Yahoo' == $('#en').text(), 'Reassert text for #en' );
|
||||||
|
|
||||||
|
var cloneTags = [
|
||||||
|
"<table/>", "<tr/>", "<td/>", "<div/>",
|
||||||
|
"<button/>", "<ul/>", "<ol/>", "<li/>",
|
||||||
|
"<input type='checkbox' />", "<select/>", "<option/>", "<textarea/>",
|
||||||
|
"<tbody/>", "<thead/>", "<tfoot/>", "<iframe/>"
|
||||||
|
];
|
||||||
|
for (var i = 0; i < cloneTags.length; i++) {
|
||||||
|
var j = $(cloneTags[i]);
|
||||||
|
equals( j[0].tagName, j.clone()[0].tagName, 'Clone a <' + cloneTags[i].substring(1));
|
||||||
|
}
|
||||||
|
|
||||||
// using contents will get comments regular, text, and comment nodes
|
// using contents will get comments regular, text, and comment nodes
|
||||||
var cl = $("#nonnodes").contents().clone();
|
var cl = $("#nonnodes").contents().clone();
|
||||||
ok( cl.length >= 2, "Check node,textnode,comment clone works (some browsers delete comments on clone)" );
|
ok( cl.length >= 2, "Check node,textnode,comment clone works (some browsers delete comments on clone)" );
|
||||||
|
|
Loading…
Reference in a new issue