Merge branch 'master' of github.com:jquery/jquery

This commit is contained in:
Dave Methvin 2012-10-16 15:15:00 -04:00
commit 947acfc32e
18 changed files with 542 additions and 360 deletions

View File

@ -21,14 +21,14 @@ module.exports = function( grunt ) {
return data;
}
var file = grunt.file;
var log = grunt.log;
var verbose = grunt.verbose;
var config = grunt.config;
var distpaths = [
"dist/jquery.js",
"dist/jquery.min.js"
];
var file = grunt.file,
log = grunt.log,
verbose = grunt.verbose,
config = grunt.config,
distpaths = [
"dist/jquery.js",
"dist/jquery.min.js"
];
grunt.initConfig({
pkg: "<json:package.json>",

View File

@ -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 );

View File

@ -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 = {};
})();

View File

@ -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];

View File

@ -281,9 +281,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 ) );
});
}

@ -1 +1 @@
Subproject commit 3ed4e970e262230c799eaf24cc6d889828a3d6f3
Subproject commit 406b24bc94b826c132669948fb29d39ab4921f49

View File

@ -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 ) {

View File

@ -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 ) {

View File

@ -0,0 +1,23 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr" id="html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
</style>
</head>
<body>
<div>
<script src="../../../dist/jquery.js"></script>
</div>
<script>
jQuery(function() {
window.parent.iframeCallback( jQuery.support.shrinkWrapBlocks );
});
</script>
</body>
</html>

View File

@ -1451,7 +1451,7 @@ if ( jQuery.ajax && ( !isLocal || hasPHP ) ) {
jQuery.each( [ "Same Domain", "Cross Domain" ], function( crossDomain, label ) {
asyncTest( "jQuery.ajax() - JSONP, Query String (?n)" + label, function() {
expect( 4 );
@ -1543,7 +1543,7 @@ if ( jQuery.ajax && ( !isLocal || hasPHP ) ) {
plus();
}
});
window["jsonpResults"] = function( data ) {
ok( data["data"], "JSON results returned (GET, custom callback function)" );
window["jsonpResults"] = undefined;
@ -2725,4 +2725,38 @@ if ( jQuery.ajax && ( !isLocal || hasPHP ) ) {
expect( 1 );
ok( jQuery.active === 0, "ajax active counter should be zero: " + jQuery.active );
});
test("jQuery.ajax - falsy url as argument (#10093)", function() {
expect( 4 );
jQuery.ajaxSetup({ timeout: 0 });
stop();
jQuery.when(
jQuery.ajax("").success(function(){ ok( true, "settings object - empty string" ); }),
jQuery.ajax( false ).success(function(){ ok( true, "false" ); }),
jQuery.ajax( null ).success(function(){ ok( true, "null" ); }),
jQuery.ajax( undefined ).success(function(){ ok( true, "undefined" ); })
).always(function () {
start();
});
});
test("jQuery.ajax - falsy url in settings object (#10093)", function() {
expect( 4 );
jQuery.ajaxSetup({ timeout: 0 });
stop();
jQuery.when(
jQuery.ajax({ url: "" }).success(function(){ ok( true, "settings object - empty string" ); }),
jQuery.ajax({ url: false }).success(function(){ ok( true, "false" ); }),
jQuery.ajax({ url: null }).success(function(){ ok( true, "null" ); }),
jQuery.ajax({ url: undefined }).success(function(){ ok( true, "undefined" ); })
).always(function () {
start();
});
});
}

File diff suppressed because it is too large Load Diff

View File

@ -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" );
});
}

View File

@ -50,7 +50,7 @@ var testWidth = function( val ) {
equal( jQuery(window).width(), document.documentElement.clientWidth, "Window width is equal to width reported by window/document." );
jQuery.removeData($div[0], "olddisplay", true);
jQuery._removeData( $div[0], "olddisplay" );
};
test("width()", function() {
@ -101,7 +101,7 @@ var testHeight = function( val ) {
equal( jQuery(window).height(), document.documentElement.clientHeight, "Window width is equal to width reported by window/document." );
jQuery.removeData($div[0], "olddisplay", true);
jQuery._removeData( $div[0], "olddisplay" );
};
test("height()", function() {
@ -156,7 +156,7 @@ test("innerWidth()", function() {
equal( div.innerWidth(), 0, "Make sure that disconnected nodes are handled." );
div.remove();
jQuery.removeData($div[0], "olddisplay", true);
jQuery._removeData( $div[0], "olddisplay" );
});
test("innerHeight()", function() {
@ -191,7 +191,7 @@ test("innerHeight()", function() {
equal( div.innerHeight(), 0, "Make sure that disconnected nodes are handled." );
div.remove();
jQuery.removeData($div[0], "olddisplay", true);
jQuery._removeData( $div[0], "olddisplay" );
});
test("outerWidth()", function() {
@ -229,7 +229,7 @@ test("outerWidth()", function() {
equal( div.outerWidth(), 0, "Make sure that disconnected nodes are handled." );
div.remove();
jQuery.removeData($div[0], "olddisplay", true);
jQuery._removeData( $div[0], "olddisplay" );
});
test("child of a hidden elem (or unconnected node) has accurate inner/outer/Width()/Height() see #9441 #9300", function() {
@ -375,7 +375,7 @@ test("outerHeight()", function() {
equal( div.outerHeight(), 0, "Make sure that disconnected nodes are handled." );
div.remove();
jQuery.removeData($div[0], "olddisplay", true);
jQuery._removeData( $div[0], "olddisplay" );
});
test("passing undefined is a setter #5571", function() {

View File

@ -1014,7 +1014,7 @@ jQuery.checkState = function() {
});
// manually clean data on modified element
jQuery.removeData( this, "olddisplay", true );
jQuery._removeData( this, "olddisplay" );
start();
};
@ -1148,7 +1148,7 @@ function( method, defProp ) {
equal( defProp( $elem ), startVal, "After doing .stop() halfway through show, check that state has been saved for returning to original property value." );
// Remove olddisplay data from .hide() call
jQuery.removeData( this, "olddisplay", true );
jQuery._removeData( this, "olddisplay" );
start();
});
}, animTime / 2);
@ -1498,7 +1498,7 @@ test( "animate should set display for disconnected nodes", function() {
// cleanup
jQuery.each( elems, function() {
jQuery.removeData( this[ 0 ], "olddisplay", true );
jQuery._removeData( this[ 0 ], "olddisplay" );
});
stop();
@ -1515,7 +1515,7 @@ test( "animate should set display for disconnected nodes", function() {
var callback = [function () {
strictEqual( this.style.display, "block", "set display to block with " + name );
jQuery.removeData( this, "olddisplay", true );
jQuery._removeData( this, "olddisplay" );
if ( ++i === 14 ) {
start();

View File

@ -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() {

View File

@ -119,7 +119,7 @@ test("callbacks keep their place in the queue", function() {
div.promise("fx").done(function() {
equal(counter, 4, "Deferreds resolved");
jQuery.removeData( div[0], "olddisplay", true );
jQuery._removeData( div[0], "olddisplay" );
start();
});
});

View File

@ -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,

View File

@ -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("<div/>").add("#sndp");
ok( !divs[0].parentNode, "Make sure the first element is still the disconnected node." );
divs = jQuery("<div>test</div>").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("<div/>");
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("<div/>");