From ce5784a480ee6dc355fc961ab8bcd5828dabcbb6 Mon Sep 17 00:00:00 2001 From: Ben Truyman Date: Tue, 16 Oct 2012 11:37:15 -0400 Subject: Handle a falsy URL in the settings object for jQuery.ajax. Fixes #10093, Closes gh-979 --- src/ajax.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ajax.js b/src/ajax.js index 394c84e66..3f71f8c6e 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -247,6 +247,7 @@ jQuery.extend({ target = jQuery.ajaxSettings; } ajaxExtend( target, settings ); + return target; }, @@ -557,8 +558,9 @@ jQuery.extend({ // Remove hash character (#7531: and string promotion) // Add protocol if not provided (#5866: IE7 issue with protocol-less urls) + // Handle falsy url in the settings object (#10093: consistency with old signature) // We also use the url parameter if available - s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" ); + s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" ); // Extract dataTypes list s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( core_rspace ); -- cgit v1.2.3 From 420dcc58423dcfd3848fb62586da184b914cff22 Mon Sep 17 00:00:00 2001 From: Timmy Willison Date: Tue, 16 Oct 2012 11:52:48 -0400 Subject: Update Sizzle: allows disconnected sorting. Change add to always sort with added nodes, even when disconnected. --- src/sizzle | 2 +- src/traversing.js | 4 +--- test/unit/traversing.js | 9 +++------ 3 files changed, 5 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/sizzle b/src/sizzle index 3ed4e970e..f69014414 160000 --- a/src/sizzle +++ b/src/sizzle @@ -1 +1 @@ -Subproject commit 3ed4e970e262230c799eaf24cc6d889828a3d6f3 +Subproject commit f690144148d95adc867fa2a7e25be0e05eb2ecc7 diff --git a/src/traversing.js b/src/traversing.js index d92bec4cb..365bb2947 100644 --- a/src/traversing.js +++ b/src/traversing.js @@ -132,9 +132,7 @@ jQuery.fn.extend({ jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ), all = jQuery.merge( this.get(), set ); - return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ? - all : - jQuery.unique( all ) ); + return this.pushStack( jQuery.unique(all) ); }, addBack: function( selector ) { diff --git a/test/unit/traversing.js b/test/unit/traversing.js index b93bede29..96b044977 100644 --- a/test/unit/traversing.js +++ b/test/unit/traversing.js @@ -582,7 +582,7 @@ test("contents()", function() { }); test("add(String|Element|Array|undefined)", function() { - expect(16); + expect( 15 ); deepEqual( jQuery("#sndp").add("#en").add("#sap").get(), q("sndp", "en", "sap"), "Check elements from document" ); deepEqual( jQuery("#sndp").add( jQuery("#en")[0] ).add( jQuery("#sap") ).get(), q("sndp", "en", "sap"), "Check elements from document" ); @@ -597,13 +597,10 @@ test("add(String|Element|Array|undefined)", function() { //equal( jQuery([]).add(jQuery("#form")[0].elements).length, jQuery(jQuery("#form")[0].elements).length, "Array in constructor must equals array in add()" ); var divs = jQuery("
").add("#sndp"); - ok( !divs[0].parentNode, "Make sure the first element is still the disconnected node." ); - - divs = jQuery("
test
").add("#sndp"); - equal( divs[0].parentNode.nodeType, 11, "Make sure the first element is still the disconnected node." ); + ok( divs[0].parentNode, "Sort with the disconnected node last (started with disconnected first)." ); divs = jQuery("#sndp").add("
"); - ok( !divs[1].parentNode, "Make sure the first element is still the disconnected node." ); + ok( !divs[1].parentNode, "Sort with the disconnected node last." ); var tmp = jQuery("
"); -- cgit v1.2.3 From 861476eb3fb5e378fdbb4e86e4737daf6de27f13 Mon Sep 17 00:00:00 2001 From: Mike Petrovich Date: Tue, 16 Oct 2012 12:22:31 -0400 Subject: Fixes #11635, Explicit overflow:auto is overridden by inline overflow:hidden during animation, closes gh-981 --- src/sizzle | 2 +- src/support.js | 2 +- test/data/support/shrinkWrapBlocks.html | 23 +++++++++++++++++++++++ test/unit/support.js | 5 +++++ 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 test/data/support/shrinkWrapBlocks.html (limited to 'src') diff --git a/src/sizzle b/src/sizzle index f69014414..3ed4e970e 160000 --- a/src/sizzle +++ b/src/sizzle @@ -1 +1 @@ -Subproject commit f690144148d95adc867fa2a7e25be0e05eb2ecc7 +Subproject commit 3ed4e970e262230c799eaf24cc6d889828a3d6f3 diff --git a/src/support.js b/src/support.js index f998f1270..7629c38e7 100644 --- a/src/support.js +++ b/src/support.js @@ -172,7 +172,7 @@ jQuery.support = (function() { // Run tests that need a body at doc ready jQuery(function() { var container, div, tds, marginDiv, - divReset = "padding:0;margin:0;border:0;display:block;overflow:hidden;", + divReset = "padding:0;margin:0;border:0;display:block;overflow:hidden;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;", body = document.getElementsByTagName("body")[0]; if ( !body ) { diff --git a/test/data/support/shrinkWrapBlocks.html b/test/data/support/shrinkWrapBlocks.html new file mode 100644 index 000000000..af1493937 --- /dev/null +++ b/test/data/support/shrinkWrapBlocks.html @@ -0,0 +1,23 @@ + + + + + + + +
+ +
+ + + diff --git a/test/unit/support.js b/test/unit/support.js index 57378a021..fed13c7dd 100644 --- a/test/unit/support.js +++ b/test/unit/support.js @@ -38,6 +38,11 @@ testIframeWithCallback( "A background on the testElement does not cause IE8 to c ok( true, "IE8 does not crash" ); }); +testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlocks", "support/shrinkWrapBlocks.html", function( shrinkWrapBlocks ) { + expect( 1 ); + strictEqual( shrinkWrapBlocks, jQuery.support.shrinkWrapBlocks, "jQuery.support.shrinkWrapBlocks properties are the same" ); +}); + (function() { var userAgent = window.navigator.userAgent, -- cgit v1.2.3 From bf145b6f3e953b53408f3fe52f24ccded38e44d3 Mon Sep 17 00:00:00 2001 From: Timmy Willison Date: Tue, 16 Oct 2012 13:28:57 -0400 Subject: Sizzle was accidentally reverted --- src/sizzle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/sizzle b/src/sizzle index 3ed4e970e..f69014414 160000 --- a/src/sizzle +++ b/src/sizzle @@ -1 +1 @@ -Subproject commit 3ed4e970e262230c799eaf24cc6d889828a3d6f3 +Subproject commit f690144148d95adc867fa2a7e25be0e05eb2ecc7 -- cgit v1.2.3 From e83bc970f2dc11fc0fd545cb0ec756a0eab64eda Mon Sep 17 00:00:00 2001 From: Greg Lavallee Date: Tue, 16 Oct 2012 14:36:47 -0400 Subject: Fixes #12736. Move hover event hack to deprecated.js for removal in 1.9. Closes gh-982. Signed-off-by: Timmy Willison --- src/deprecated.js | 61 ++++++++++++++++++++++++++++++++++++------------- src/event.js | 10 +++----- test/unit/deprecated.js | 29 +++++++++++++++++++++++ test/unit/event.js | 28 ++--------------------- 4 files changed, 79 insertions(+), 49 deletions(-) (limited to 'src') diff --git a/src/deprecated.js b/src/deprecated.js index 4ea47b333..3c2763ddc 100644 --- a/src/deprecated.js +++ b/src/deprecated.js @@ -1,7 +1,12 @@ // Limit scope pollution from any deprecated API (function() { -var matched, browser; +var matched, browser, eventAdd, eventRemove, + oldToggle = jQuery.fn.toggle, + rhoverHack = /(?:^|\s)hover(\.\S+|)\b/, + hoverHack = function( events ) { + return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" ); + }; // Use of jQuery.browser is frowned upon. // More details: http://api.jquery.com/jQuery.browser @@ -60,10 +65,6 @@ jQuery.sub = function() { return jQuerySub; }; -// Unused in 1.8, left in so attrFn-stabbers won't die; remove in 1.9 -jQuery.attrFn = {}; - -var oldToggle = jQuery.fn.toggle; jQuery.fn.toggle = function( fn, fn2 ) { if ( !jQuery.isFunction( fn ) || !jQuery.isFunction( fn2 ) ) { @@ -72,19 +73,19 @@ jQuery.fn.toggle = function( fn, fn2 ) { // Save reference to arguments for access in closure var args = arguments, - guid = fn.guid || jQuery.guid++, - i = 0, - toggler = function( event ) { - // Figure out which function to execute - var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i; - jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 ); + guid = fn.guid || jQuery.guid++, + i = 0, + toggler = function( event ) { + // Figure out which function to execute + var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i; + jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 ); - // Make sure that clicks stop - event.preventDefault(); + // Make sure that clicks stop + event.preventDefault(); - // and execute the function - return args[ lastToggle ].apply( this, arguments ) || false; - }; + // and execute the function + return args[ lastToggle ].apply( this, arguments ) || false; + }; // link all the functions, so any of them can unbind this click handler toggler.guid = guid; @@ -95,4 +96,32 @@ jQuery.fn.toggle = function( fn, fn2 ) { return this.click( toggler ); }; + +// Support for 'hover' type +eventAdd = jQuery.event.add; + +// Duck punch jQuery.event.add, and jquery.event.remove +// Signatures: +// jQuery.event = { +// add: function( elem, types, handler, data, selector ) { +// remove: function( elem, types, handler, selector, mappedTypes ) { +jQuery.event.add = function( elem, types, handler, data, selector ){ + if ( types ) { + types = hoverHack( types ); + } + eventAdd.call( this, elem, types, handler, data, selector ); +}; + +eventRemove = jQuery.event.remove; + +jQuery.event.remove = function( elem, types, handler, selector, mappedTypes ){ + if ( types ) { + types = hoverHack( types ); + } + eventRemove.call( this, elem, types, handler, selector, mappedTypes ); +}; + +// Unused in 1.8, left in so attrFn-stabbers won't die; remove in 1.9 +jQuery.attrFn = {}; + })(); diff --git a/src/event.js b/src/event.js index 3fea1a1be..f68a09c54 100644 --- a/src/event.js +++ b/src/event.js @@ -1,12 +1,8 @@ var rformElems = /^(?:textarea|input|select)$/i, rtypenamespace = /^([^\.]*|)(?:\.(.+)|)$/, - rhoverHack = /(?:^|\s)hover(\.\S+|)\b/, rkeyEvent = /^key/, rmouseEvent = /^(?:mouse|contextmenu)|click/, - rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, - hoverHack = function( events ) { - return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" ); - }; + rfocusMorph = /^(?:focusinfocus|focusoutblur)$/; /* * Helper functions for managing events -- not part of the public interface. @@ -56,7 +52,7 @@ jQuery.event = { // Handle multiple events separated by a space // jQuery(...).bind("mouseover mouseout", fn); - types = jQuery.trim( hoverHack(types) ).split( " " ); + types = jQuery.trim( types ).split( " " ); for ( t = 0; t < types.length; t++ ) { tns = rtypenamespace.exec( types[t] ) || []; @@ -139,7 +135,7 @@ jQuery.event = { } // Once for each type.namespace in types; type may be omitted - types = jQuery.trim( hoverHack( types || "" ) ).split(" "); + types = jQuery.trim( types ).split(" "); for ( t = 0; t < types.length; t++ ) { tns = rtypenamespace.exec( types[t] ) || []; type = origType = tns[1]; diff --git a/test/unit/deprecated.js b/test/unit/deprecated.js index f5787e518..3bce98d57 100644 --- a/test/unit/deprecated.js +++ b/test/unit/deprecated.js @@ -107,4 +107,33 @@ if ( jQuery.browser ) { ok(!!jQuery.attrFn, "attrFnPresent"); }); + test("hover pseudo-event", function() { + expect(2); + + var balance = 0; + jQuery( "#firstp" ) + .on( "hovercraft", function() { + ok( false, "hovercraft is full of ills" ); + }) + .on( "click.hover.me.not", function( e ) { + equal( e.handleObj.namespace, "hover.me.not", "hover hack doesn't mangle namespaces" ); + }) + .bind("hover", function( e ) { + if ( e.type === "mouseenter" ) { + balance++; + } else if ( e.type === "mouseleave" ) { + balance--; + } else { + ok( false, "hover pseudo: unknown event type "+e.type ); + } + }) + .trigger("click") + .trigger("mouseenter") + .trigger("mouseleave") + .unbind("hover") + .trigger("mouseenter"); + + equal( balance, 0, "hover pseudo-event" ); + }); + } diff --git a/test/unit/event.js b/test/unit/event.js index e626ede1d..d6c24436a 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -798,8 +798,8 @@ test("unbind(eventObject)", function() { assert( 0 ); }); -test("hover() and hover pseudo-event", function() { - expect(3); +test("hover() mouseenter mouseleave", function() { + expect(1); var times = 0, handler1 = function( event ) { ++times; }, @@ -817,30 +817,6 @@ test("hover() and hover pseudo-event", function() { equal( times, 4, "hover handlers fired" ); - var balance = 0; - jQuery( "#firstp" ) - .on( "hovercraft", function() { - ok( false, "hovercraft is full of ills" ); - }) - .on( "click.hover.me.not", function( e ) { - equal( e.handleObj.namespace, "hover.me.not", "hover hack doesn't mangle namespaces" ); - }) - .bind("hover", function( e ) { - if ( e.type === "mouseenter" ) { - balance++; - } else if ( e.type === "mouseleave" ) { - balance--; - } else { - ok( false, "hover pseudo: unknown event type "+e.type ); - } - }) - .trigger("click") - .trigger("mouseenter") - .trigger("mouseleave") - .unbind("hover") - .trigger("mouseenter"); - - equal( balance, 0, "hover pseudo-event" ); }); test("mouseover triggers mouseenter", function() { -- cgit v1.2.3 From 1fdc0b7f7873885aebe279af9ffccb3900d804b2 Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Tue, 16 Oct 2012 15:01:59 -0400 Subject: Replace unknown, mysterious html arg to replaceWith(fn...), with just the current node. --- src/manipulation.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/manipulation.js b/src/manipulation.js index aced4567b..5734b33d9 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -263,9 +263,12 @@ jQuery.fn.extend({ // Make sure that the elements are removed from the DOM before they are inserted // this can help fix replacing a parent with child elements if ( jQuery.isFunction( value ) ) { - return this.each(function(i) { - var self = jQuery(this), old = self.html(); - self.replaceWith( value.call( this, i, old ) ); + return this.each(function( index ) { + // HTML argument replaced by "this" element + // 1. There were no supporting tests + // 2. There was no internal code relying on this + // 3. There was no documentation of an html argument + jQuery( this ).replaceWith( value.call( this, index, this ) ); }); } -- cgit v1.2.3 From 0ea348bb5b4b8bac7b3bd35bd37396847847d766 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Tue, 16 Oct 2012 15:02:26 -0400 Subject: update sizzle for test failures --- src/sizzle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/sizzle b/src/sizzle index f69014414..406b24bc9 160000 --- a/src/sizzle +++ b/src/sizzle @@ -1 +1 @@ -Subproject commit f690144148d95adc867fa2a7e25be0e05eb2ecc7 +Subproject commit 406b24bc94b826c132669948fb29d39ab4921f49 -- cgit v1.2.3 From aeb036893d35fe036f5d0e119b6ece46eaf3931b Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Tue, 16 Oct 2012 15:06:51 -0400 Subject: Fixes busted indents. Sorry folks --- src/manipulation.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/manipulation.js b/src/manipulation.js index 5734b33d9..27de3456d 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -264,10 +264,10 @@ jQuery.fn.extend({ // this can help fix replacing a parent with child elements if ( jQuery.isFunction( value ) ) { return this.each(function( index ) { - // HTML argument replaced by "this" element - // 1. There were no supporting tests - // 2. There was no internal code relying on this - // 3. There was no documentation of an html argument + // HTML argument replaced by "this" element + // 1. There were no supporting tests + // 2. There was no internal code relying on this + // 3. There was no documentation of an html argument jQuery( this ).replaceWith( value.call( this, index, this ) ); }); } -- cgit v1.2.3