From 118c8c4600b62d6de2b0248ae27626da74dcf5b2 Mon Sep 17 00:00:00 2001 From: rwldrn Date: Tue, 9 Nov 2010 18:06:33 -0500 Subject: [PATCH 001/194] Fixes #7397; 4 supporting unit tests --- src/effects.js | 11 ++++++----- test/unit/effects.js | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/src/effects.js b/src/effects.js index 51ce0c57..f9c682c9 100644 --- a/src/effects.js +++ b/src/effects.js @@ -60,11 +60,12 @@ jQuery.fn.extend({ } else { for ( var i = 0, j = this.length; i < j; i++ ) { - var display = jQuery.css( this[i], "display" ); - - if ( display !== "none" ) { - jQuery.data( this[i], "olddisplay", display ); - } + var display = jQuery.css( this[i], "display" ), + old = jQuery.data( this[i], "olddisplay" ); + + if ( !old && display !== "none" ) { + jQuery.data( this[i], "olddisplay", display ); + } } // Set the display of the elements in a second loop diff --git a/test/unit/effects.js b/test/unit/effects.js index 74b336f1..aca92638 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(); From 8f2667f4c09d14de413cac1e3c5fc5783521b0e0 Mon Sep 17 00:00:00 2001 From: rwldrn Date: Tue, 9 Nov 2010 18:20:27 -0500 Subject: [PATCH 002/194] Clean #7397; Removed unnec. var declaration --- src/effects.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/effects.js b/src/effects.js index f9c682c9..bac2e1d5 100644 --- a/src/effects.js +++ b/src/effects.js @@ -60,10 +60,9 @@ jQuery.fn.extend({ } else { for ( var i = 0, j = this.length; i < j; i++ ) { - var display = jQuery.css( this[i], "display" ), - old = jQuery.data( this[i], "olddisplay" ); + var display = jQuery.css( this[i], "display" ); - if ( !old && display !== "none" ) { + if ( !jQuery.data( this[i], "olddisplay" ) && display !== "none" ) { jQuery.data( this[i], "olddisplay", display ); } } From 2a23650a19ed4db2d031697638bdd71c06f44492 Mon Sep 17 00:00:00 2001 From: rwldrn Date: Wed, 10 Nov 2010 10:23:48 -0500 Subject: [PATCH 003/194] Updating #7397 unit tests to correctly test for a persisted display value --- test/unit/effects.js | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/test/unit/effects.js b/test/unit/effects.js index aca92638..96907968 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.text('Saving...').fadeIn(100, function() { - - equal($span.css("display"), "block", "Expecting display: block"); - - $span.text('Saved!').fadeOut(100, function () { + $span.show(); - equal($span.css("display"), "none", "Expecting display: none"); + display = $span.css("display"); + + $span.hide(); + + $span.fadeIn(100, function() { + + equals($span.css("display"), display, "Expecting display: " + display); + + $span.fadeOut(100, function () { + + 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(); }); From 50170e618059d10132a5319c64660a631b095f44 Mon Sep 17 00:00:00 2001 From: Russell Holbrook Date: Mon, 22 Nov 2010 18:26:46 -0500 Subject: [PATCH 004/194] jQuery.fn.offset no longer returns ClientRect object for disconnected elements Instead of returning box, which is a ClientRect, we take the top and left box values and place them into a generic object. --- src/offset.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/offset.js b/src/offset.js index 3fb2917b..dab053e0 100644 --- a/src/offset.js +++ b/src/offset.js @@ -30,7 +30,7 @@ if ( "getBoundingClientRect" in document.documentElement ) { // Make sure we're not dealing with a disconnected DOM node if ( !box || !jQuery.contains( docElem, elem ) ) { - return box || { top: 0, left: 0 }; + return box ? { top: box.top, left: box.left } : { top: 0, left: 0 }; } var body = doc.body, From 00f1dfdd57fd8478688f9d201e539e0bf3946be2 Mon Sep 17 00:00:00 2001 From: rwldrn Date: Thu, 9 Dec 2010 12:44:52 -0500 Subject: [PATCH 005/194] Reorders condition at L65 for efficiency --- src/effects.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/effects.js b/src/effects.js index bac2e1d5..feaf02b5 100644 --- a/src/effects.js +++ b/src/effects.js @@ -62,8 +62,8 @@ jQuery.fn.extend({ for ( var i = 0, j = this.length; i < j; i++ ) { var display = jQuery.css( this[i], "display" ); - if ( !jQuery.data( this[i], "olddisplay" ) && display !== "none" ) { - jQuery.data( this[i], "olddisplay", display ); + if ( display !== "none" && !jQuery.data( this[i], "olddisplay" ) ) { + jQuery.data( this[i], "olddisplay", display ); } } From 5b2408147b9cf9b7f49a07ebe97b20c398568e22 Mon Sep 17 00:00:00 2001 From: rwldrn Date: Thu, 9 Dec 2010 12:47:53 -0500 Subject: [PATCH 006/194] Whitespace correction --- src/effects.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/effects.js b/src/effects.js index feaf02b5..f976c41a 100644 --- a/src/effects.js +++ b/src/effects.js @@ -62,9 +62,9 @@ jQuery.fn.extend({ for ( var i = 0, j = this.length; i < j; i++ ) { var display = jQuery.css( this[i], "display" ); - if ( display !== "none" && !jQuery.data( this[i], "olddisplay" ) ) { - jQuery.data( this[i], "olddisplay", display ); - } + if ( display !== "none" && !jQuery.data( this[i], "olddisplay" ) ) { + jQuery.data( this[i], "olddisplay", display ); + } } // Set the display of the elements in a second loop From 1cdd9f8cab5b86d76ea20e996a9c636dd6f5ca6e Mon Sep 17 00:00:00 2001 From: rwldrn Date: Thu, 9 Dec 2010 12:48:52 -0500 Subject: [PATCH 007/194] Whitespace correction --- src/effects.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/effects.js b/src/effects.js index f976c41a..482c44d5 100644 --- a/src/effects.js +++ b/src/effects.js @@ -62,9 +62,9 @@ jQuery.fn.extend({ for ( var i = 0, j = this.length; i < j; i++ ) { var display = jQuery.css( this[i], "display" ); - if ( display !== "none" && !jQuery.data( this[i], "olddisplay" ) ) { - jQuery.data( this[i], "olddisplay", display ); - } + if ( display !== "none" && !jQuery.data( this[i], "olddisplay" ) ) { + jQuery.data( this[i], "olddisplay", display ); + } } // Set the display of the elements in a second loop From a59bb30d0a5ea0d3d73285c6fed0fbe00b23321f Mon Sep 17 00:00:00 2001 From: rwldrn Date: Thu, 9 Dec 2010 12:50:01 -0500 Subject: [PATCH 008/194] Whitespace correction --- src/effects.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/effects.js b/src/effects.js index 482c44d5..98f969f0 100644 --- a/src/effects.js +++ b/src/effects.js @@ -63,7 +63,7 @@ jQuery.fn.extend({ var display = jQuery.css( this[i], "display" ); if ( display !== "none" && !jQuery.data( this[i], "olddisplay" ) ) { - jQuery.data( this[i], "olddisplay", display ); + jQuery.data( this[i], "olddisplay", display ); } } From 291b1edf444f30d9360a42c8d563e26eaf1a2ddb Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Thu, 16 Dec 2010 01:29:06 -0600 Subject: [PATCH 009/194] Address some code style issues in the clone fix. --- src/manipulation.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/manipulation.js b/src/manipulation.js index 63203ef3..7dea3493 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -415,17 +415,15 @@ function cloneFixAttributes(src, dest) { // attribute) to identify the type of content to display if ( nodeName === "object" ) { dest.outerHTML = src.outerHTML; - } // IE6-8 fails to persist the checked state of a cloned checkbox // or radio button - else if ( nodeName === "input" && src.checked ) { + } else if ( nodeName === "input" && src.checked ) { dest.defaultChecked = dest.checked = src.checked; - } // IE6-8 fails to return the selected option to the default selected // state when cloning options - else if ( nodeName === "option" ) { + } else if ( nodeName === "option" ) { dest.selected = src.defaultSelected; } From faefbb1ad0b81e8001b582d06d5bd9c9236e62ce Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Sun, 19 Dec 2010 15:33:53 -0600 Subject: [PATCH 010/194] 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(-) diff --git a/src/data.js b/src/data.js index f1e031ff..120fe718 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 7dea3493..c23f62ed 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 d49029eb..52f76ed6 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("