X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fmanipulation.js;h=52f76ed6983b9e4cdf05189bee124611e93e7afc;hb=2a47ceae5b9bdc45fdc890e3cd5ec01c82db1688;hp=71a501ac52c6578b47bb10b5893e85af80e20aa1;hpb=7481a3645af63cef1406687190fd62bdfb1bf254;p=jquery.git
diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js
index 71a501a..52f76ed 100644
--- a/test/unit/manipulation.js
+++ b/test/unit/manipulation.js
@@ -51,7 +51,7 @@ test("text(Function) with incoming value", function() {
});
var testWrap = function(val) {
- expect(18);
+ expect(19);
var defaultText = 'Try them out:'
var result = jQuery('#first').wrap(val( '
' )).text();
equals( defaultText, result, 'Check for wrapping of on-the-fly html' );
@@ -80,10 +80,20 @@ var testWrap = function(val) {
equals( jQuery("#nonnodes > i").text(), j.text(), "Check node,textnode,comment wraps doesn't hurt text" );
// Try wrapping a disconnected node
+ var cacheLength = 0;
+ for (var i in jQuery.cache) {
+ cacheLength++;
+ }
+
j = jQuery("").wrap(val( "" ));
equals( j[0].nodeName.toUpperCase(), "LABEL", "Element is a label" );
equals( j[0].parentNode.nodeName.toUpperCase(), "LI", "Element has been wrapped" );
+ for (i in jQuery.cache) {
+ cacheLength--;
+ }
+ equals(cacheLength, 0, "No memory leak in jQuery.cache (bug #7165)");
+
// Wrap an element containing a text node
j = jQuery("").wrap("
test
");
equals( j[0].previousSibling.nodeType, 3, "Make sure the previous node is a text element" );
@@ -382,13 +392,13 @@ test("append(Function) with incoming value", function() {
});
test("append the same fragment with events (Bug #6997, 5566)", function () {
- expect(2 + (document.fireEvent ? 1 : 0));
+ expect(4 + (document.fireEvent ? 1 : 0));
stop(1000);
var element;
// This patch modified the way that cloning occurs in IE; we need to make sure that
- // native event handlers on the original object donât get disturbed when they are
+ // native event handlers on the original object don't get disturbed when they are
// modified on the clone
if (!jQuery.support.noCloneEvent && document.fireEvent) {
element = jQuery("div:first").click(function () {
@@ -413,6 +423,14 @@ test("append the same fragment with events (Bug #6997, 5566)", function () {
jQuery("#listWithTabIndex li").before(element);
jQuery("#listWithTabIndex li.test6997").eq(1).click();
+
+ element = jQuery("");
+
+ equals( element.clone().find("option:selected").val(), element.find("option:selected").val(), "Selected option cloned correctly" );
+
+ element = jQuery("").attr('checked', 'checked');
+
+ equals( element.clone().is(":checked"), element.is(":checked"), "Checked input cloned correctly" );
});
test("appendTo(String|Element|Array<Element>|jQuery)", function() {
@@ -848,7 +866,7 @@ test("replaceAll(String|Element|Array<Element>|jQuery)", function() {
});
test("clone()", function() {
- expect(35);
+ expect(37);
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' );
@@ -890,7 +908,7 @@ test("clone()", function() {
// this is technically an invalid object, but because of the special
// classid instantiation it is the only kind that IE has trouble with,
- // so letâs test with it too.
+ // so let's test with it too.
div = jQuery("").html('');
clone = div.clone(true);
@@ -906,10 +924,16 @@ test("clone()", function() {
equals( clone.html(), div.html(), "Element contents cloned" );
equals( clone[0].nodeName.toUpperCase(), "DIV", "DIV element cloned" );
- div = jQuery("").data({ a: true, b: true });
- div = div.clone(true);
- equals( div.data("a"), true, "Data cloned." );
- equals( div.data("b"), true, "Data cloned." );
+ div = jQuery("").data({
+ a: true, b: true,
+ c: { nesty: ["Block", "Head"] }
+ });
+ var div2 = div.clone(true);
+ equals( div2.data("a"), true, "Data cloned." );
+ equals( div2.data("b"), true, "Data cloned." );
+ var c = div2.data("c");
+ c.nesty[0] = "Fish";
+ equals( div.data("c").nesty[0], "Block", "Ensure cloned element data is deep copied (Bug #7717)" );
var form = document.createElement("form");
form.action = "/test/";
@@ -918,6 +942,8 @@ test("clone()", function() {
form.appendChild( div );
equals( jQuery(form).clone().children().length, 1, "Make sure we just get the form back." );
+
+ equal( jQuery("body").clone().children()[0].id, "qunit-header", "Make sure cloning body works" );
});
if (!isLocal) {