Ticket #2184: 2184.diff
File 2184.diff, 1.8 KB (added by , 14 years ago) |
---|
-
test/unit/core.js
955 955 }); 956 956 957 957 test("clone()", function() { 958 expect( 4);958 expect(20); 959 959 ok( 'This is a normal link: Yahoo' == $('#en').text(), 'Assert text for #en' ); 960 960 var clone = $('#yahoo').clone(); 961 961 ok( 'Try them out:Yahoo' == $('#first').append(clone).text(), 'Check for clone' ); 962 962 ok( 'This is a normal link: Yahoo' == $('#en').text(), 'Reassert text for #en' ); 963 964 var cloneTags = [ 965 "<table/>", "<tr/>", "<td/>", "<div/>", 966 "<button/>", "<ul/>", "<ol/>", "<li/>", 967 "<input type='checkbox' />", "<select/>", "<option/>", "<textarea/>", 968 "<tbody/>", "<thead/>", "<tfoot/>", "<iframe/>" 969 ]; 970 for (var i = 0; i < cloneTags.length; i++) { 971 var j = $(cloneTags[i]); 972 equals( j[0].tagName, j.clone()[0].tagName, 'Clone a <' + cloneTags[i].substring(1)); 973 } 974 963 975 // using contents will get comments regular, text, and comment nodes 964 976 var cl = $("#nonnodes").contents().clone(); 965 977 ok( cl.length >= 2, "Check node,textnode,comment clone works (some browsers delete comments on clone)" ); -
src/core.js
303 303 // as properties will not be copied (such as the 304 304 // the name attribute on an input). 305 305 var clone = this.cloneNode(true), 306 container = document.createElement("div"), 307 container2 = document.createElement("div"); 306 container = document.createElement("div"); 308 307 container.appendChild(clone); 309 container2.innerHTML = container.innerHTML; 310 return container2.firstChild; 308 return jQuery.clean([container.innerHTML])[0]; 311 309 } else 312 310 return this.cloneNode(true); 313 311 });