aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJohn Resig <jeresig@gmail.com>2009-02-09 14:48:15 +0000
committerJohn Resig <jeresig@gmail.com>2009-02-09 14:48:15 +0000
commitce90accc58d213fcf567ab2ca464ee9164601dc4 (patch)
tree4a9ace5c3c7616e337569b6039685e88c2f999c7 /test
parentf38648c7cd3a37f4070b77b2c92151f68aa66fef (diff)
downloadjquery-ce90accc58d213fcf567ab2ca464ee9164601dc4.tar.gz
jquery-ce90accc58d213fcf567ab2ca464ee9164601dc4.zip
Reworked the .clone() function in IE. Fixes jQuery bugs #3500 (jQuery expandos were causing extra elements to appear from using .html() cloning), #3254 (Mis-match in clone result length causes problem), and #2845 (Cloning an <object/> causes exceptions to be thrown).
Diffstat (limited to 'test')
-rw-r--r--test/unit/core.js27
1 files changed, 26 insertions, 1 deletions
diff --git a/test/unit/core.js b/test/unit/core.js
index 316d9e4cc..6da62be9a 100644
--- a/test/unit/core.js
+++ b/test/unit/core.js
@@ -1156,7 +1156,7 @@ test("find(String)", function() {
});
test("clone()", function() {
- expect(20);
+ expect(28);
equals( 'This is a normal link: Yahoo', jQuery('#en').text(), 'Assert text for #en' );
var clone = jQuery('#yahoo').clone();
equals( 'Try them out:Yahoo', jQuery('#first').append(clone).text(), 'Check for clone' );
@@ -1176,6 +1176,31 @@ test("clone()", function() {
// using contents will get comments regular, text, and comment nodes
var cl = jQuery("#nonnodes").contents().clone();
ok( cl.length >= 2, "Check node,textnode,comment clone works (some browsers delete comments on clone)" );
+
+ var div = jQuery("<div><ul><li>test</li></ul></div>").click(function(){
+ ok( true, "Bound event still exists." );
+ });
+
+ div = div.clone(true).clone(true);
+ equals( div.length, 1, "One element cloned" );
+ equals( div[0].nodeName.toUpperCase(), "DIV", "DIV element cloned" );
+ div.trigger("click");
+
+ div = jQuery("<div/>").append([ document.createElement("table"), document.createElement("table") ]);
+ div.find("table").click(function(){
+ ok( true, "Bound event still exists." );
+ });
+
+ div = div.clone(true);
+ equals( div.length, 1, "One element cloned" );
+ equals( div[0].nodeName.toUpperCase(), "DIV", "DIV element cloned" );
+ div.find("table:last").trigger("click");
+
+ div = jQuery("<div/>").html('<object height="355" width="425"> <param name="movie" value="http://www.youtube.com/v/JikaHBDoV3k&amp;hl=en"> <param name="wmode" value="transparent"> </object>');
+
+ div = div.clone(true);
+ equals( div.length, 1, "One element cloned" );
+ equals( div[0].nodeName.toUpperCase(), "DIV", "DIV element cloned" );
});
if (!isLocal) {