From 118c8c4600b62d6de2b0248ae27626da74dcf5b2 Mon Sep 17 00:00:00 2001 From: rwldrn Date: Tue, 9 Nov 2010 18:06:33 -0500 Subject: Fixes #7397; 4 supporting unit tests --- test/unit/effects.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'test') diff --git a/test/unit/effects.js b/test/unit/effects.js index 74b336f1f..aca926384 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -130,6 +130,41 @@ test("show(Number) - other displays", function() { }); }); + + +// Supports #7397 +test("Persist correct display value", function() { + expect(4); + QUnit.reset(); + stop(); + + // #show-tests * is set display: none in CSS + jQuery("#main").append('
'); + + var $span = jQuery("#show-tests span"), + orig = $span.css("display"), + num = 0; + + equal(orig, "none", "Expecting to start at display: none"); + + $span.text('Saving...').fadeIn(100, function() { + + equal($span.css("display"), "block", "Expecting display: block"); + + $span.text('Saved!').fadeOut(100, function () { + + equal($span.css("display"), "none", "Expecting display: none"); + + $span.text('Saving...').fadeIn(100, function() { + + equal($span.css("display"), "block", "Expecting display: block"); + + start(); + }); + }); + }); +}); + test("animate(Hash, Object, Function)", function() { expect(1); stop(); -- cgit v1.2.3 From 2a23650a19ed4db2d031697638bdd71c06f44492 Mon Sep 17 00:00:00 2001 From: rwldrn Date: Wed, 10 Nov 2010 10:23:48 -0500 Subject: Updating #7397 unit tests to correctly test for a persisted display value --- test/unit/effects.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'test') diff --git a/test/unit/effects.js b/test/unit/effects.js index aca926384..969079683 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -134,30 +134,34 @@ test("show(Number) - other displays", function() { // Supports #7397 test("Persist correct display value", function() { - expect(4); + expect(3); QUnit.reset(); stop(); // #show-tests * is set display: none in CSS - jQuery("#main").append('
'); + jQuery("#main").append('
foo
'); var $span = jQuery("#show-tests span"), - orig = $span.css("display"), - num = 0; + displayNone = $span.css("display"), + display = '', num = 0; - equal(orig, "none", "Expecting to start at display: none"); + $span.show(); + + display = $span.css("display"); + + $span.hide(); - $span.text('Saving...').fadeIn(100, function() { + $span.fadeIn(100, function() { - equal($span.css("display"), "block", "Expecting display: block"); + equals($span.css("display"), display, "Expecting display: " + display); - $span.text('Saved!').fadeOut(100, function () { + $span.fadeOut(100, function () { - equal($span.css("display"), "none", "Expecting display: none"); + equals($span.css("display"), displayNone, "Expecting display: " + displayNone); - $span.text('Saving...').fadeIn(100, function() { + $span.fadeIn(100, function() { - equal($span.css("display"), "block", "Expecting display: block"); + equals($span.css("display"), display, "Expecting display: " + display); start(); }); -- cgit v1.2.3 From faefbb1ad0b81e8001b582d06d5bd9c9236e62ce Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Sun, 19 Dec 2010 15:33:53 -0600 Subject: Fix #7717 and #7165. Thanks to dmethvin and iliakan for their help fixing these issues. --- src/data.js | 8 ++++++-- src/manipulation.js | 4 ++-- test/unit/manipulation.js | 28 ++++++++++++++++++++++------ 3 files changed, 30 insertions(+), 10 deletions(-) (limited to 'test') diff --git a/src/data.js b/src/data.js index f1e031fff..120fe718d 100644 --- a/src/data.js +++ b/src/data.js @@ -9,7 +9,7 @@ jQuery.extend({ // Please use with caution uuid: 0, - // Unique for each copy of jQuery on the page + // Unique for each copy of jQuery on the page expando: "jQuery" + jQuery.now(), // The following elements throw uncatchable exceptions if you @@ -21,6 +21,10 @@ jQuery.extend({ "applet": true }, + hasData: function( elem ) { + return !elem.nodeType || (elem[ jQuery.expando ] && !jQuery.isEmptyObject(jQuery.cache[ elem[jQuery.expando] ])); + }, + data: function( elem, name, data ) { if ( !jQuery.acceptData( elem ) ) { return; @@ -144,7 +148,7 @@ jQuery.fn.extend({ var attr = this[0].attributes, name; for ( var i = 0, l = attr.length; i < l; i++ ) { name = attr[i].name; - + if ( name.indexOf( "data-" ) === 0 ) { name = name.substr( 5 ); dataAttr( this[0], name, data[ name ] ); diff --git a/src/manipulation.js b/src/manipulation.js index 7dea3493c..c23f62ed1 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -373,12 +373,12 @@ function cloneCopyEvent(orig, ret) { var i = 0; ret.each(function() { - if ( this.nodeType !== 1 || this.nodeName !== (orig[i] && orig[i].nodeName) ) { + if ( this.nodeType !== 1 || this.nodeName !== (orig[i] && orig[i].nodeName) || !jQuery.hasData(orig[i]) ) { return; } var oldData = jQuery.data( orig[i++] ), - curData = jQuery.data( this, oldData ), + curData = jQuery.data( this, jQuery.extend(true, {}, oldData) ), events = oldData && oldData.events; if ( events ) { diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index d49029eb8..52f76ed69 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("