Fix #2184 by using the jQuery.clean() function instead of a direct innerHTML assignme...
[jquery.git] / test / unit / core.js
index 1d8fb6d..7b0aad4 100644 (file)
@@ -252,11 +252,14 @@ test("get(Number)", function() {
 });
 
 test("add(String|Element|Array|undefined)", function() {
-       expect(9);
+       expect(8);
        isSet( $("#sndp").add("#en").add("#sap").get(), q("sndp", "en", "sap"), "Check elements from document" );
        isSet( $("#sndp").add( $("#en")[0] ).add( $("#sap") ).get(), q("sndp", "en", "sap"), "Check elements from document" );
        ok( $([]).add($("#form")[0].elements).length >= 13, "Check elements from array" );
-       equals( $([]).add($("#form")[0].elements).length, $($("#form")[0].elements).length, "Array in constructor must equals array in add()" );
+
+       // For the time being, we're discontinuing support for $(form.elements) since it's ambiguous in IE
+       // use $([]).add(form.elements) instead.
+       //equals( $([]).add($("#form")[0].elements).length, $($("#form")[0].elements).length, "Array in constructor must equals array in add()" );
        
        var x = $([]).add($("<p id='x1'>xxx</p>")).add($("<p id='x2'>xxx</p>"));
        ok( x[0].id == "x1", "Check on-the-fly element1" );
@@ -952,11 +955,23 @@ test("find(String)", function() {
 });
 
 test("clone()", function() {
-       expect(4);
+       expect(20);
        ok( 'This is a normal link: Yahoo' == $('#en').text(), 'Assert text for #en' );
        var clone = $('#yahoo').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' );
+
+       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 &lt;' + cloneTags[i].substring(1));
+       }
+
        // using contents will get comments regular, text, and comment nodes
        var cl = $("#nonnodes").contents().clone();
        ok( cl.length >= 2, "Check node,textnode,comment clone works (some browsers delete comments on clone)" );