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,11 +21,11 @@ module.exports = function( grunt ) {
return data; return data;
} }
var file = grunt.file; var file = grunt.file,
var log = grunt.log; log = grunt.log,
var verbose = grunt.verbose; verbose = grunt.verbose,
var config = grunt.config; config = grunt.config,
var distpaths = [ distpaths = [
"dist/jquery.js", "dist/jquery.js",
"dist/jquery.min.js" "dist/jquery.min.js"
]; ];

View File

@ -247,6 +247,7 @@ jQuery.extend({
target = jQuery.ajaxSettings; target = jQuery.ajaxSettings;
} }
ajaxExtend( target, settings ); ajaxExtend( target, settings );
return target; return target;
}, },
@ -557,8 +558,9 @@ jQuery.extend({
// Remove hash character (#7531: and string promotion) // Remove hash character (#7531: and string promotion)
// Add protocol if not provided (#5866: IE7 issue with protocol-less urls) // 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 // 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 // Extract dataTypes list
s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( core_rspace ); s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( core_rspace );

View File

@ -1,7 +1,12 @@
// Limit scope pollution from any deprecated API // Limit scope pollution from any deprecated API
(function() { (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. // Use of jQuery.browser is frowned upon.
// More details: http://api.jquery.com/jQuery.browser // More details: http://api.jquery.com/jQuery.browser
@ -60,10 +65,6 @@ jQuery.sub = function() {
return jQuerySub; 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 ) { jQuery.fn.toggle = function( fn, fn2 ) {
if ( !jQuery.isFunction( fn ) || !jQuery.isFunction( fn2 ) ) { if ( !jQuery.isFunction( fn ) || !jQuery.isFunction( fn2 ) ) {
@ -95,4 +96,32 @@ jQuery.fn.toggle = function( fn, fn2 ) {
return this.click( toggler ); 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, var rformElems = /^(?:textarea|input|select)$/i,
rtypenamespace = /^([^\.]*|)(?:\.(.+)|)$/, rtypenamespace = /^([^\.]*|)(?:\.(.+)|)$/,
rhoverHack = /(?:^|\s)hover(\.\S+|)\b/,
rkeyEvent = /^key/, rkeyEvent = /^key/,
rmouseEvent = /^(?:mouse|contextmenu)|click/, rmouseEvent = /^(?:mouse|contextmenu)|click/,
rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, rfocusMorph = /^(?:focusinfocus|focusoutblur)$/;
hoverHack = function( events ) {
return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
};
/* /*
* Helper functions for managing events -- not part of the public interface. * Helper functions for managing events -- not part of the public interface.
@ -56,7 +52,7 @@ jQuery.event = {
// Handle multiple events separated by a space // Handle multiple events separated by a space
// jQuery(...).bind("mouseover mouseout", fn); // jQuery(...).bind("mouseover mouseout", fn);
types = jQuery.trim( hoverHack(types) ).split( " " ); types = jQuery.trim( types ).split( " " );
for ( t = 0; t < types.length; t++ ) { for ( t = 0; t < types.length; t++ ) {
tns = rtypenamespace.exec( types[t] ) || []; tns = rtypenamespace.exec( types[t] ) || [];
@ -139,7 +135,7 @@ jQuery.event = {
} }
// Once for each type.namespace in types; type may be omitted // 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++ ) { for ( t = 0; t < types.length; t++ ) {
tns = rtypenamespace.exec( types[t] ) || []; tns = rtypenamespace.exec( types[t] ) || [];
type = origType = tns[1]; 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 // Make sure that the elements are removed from the DOM before they are inserted
// this can help fix replacing a parent with child elements // this can help fix replacing a parent with child elements
if ( jQuery.isFunction( value ) ) { if ( jQuery.isFunction( value ) ) {
return this.each(function(i) { return this.each(function( index ) {
var self = jQuery(this), old = self.html(); // HTML argument replaced by "this" element
self.replaceWith( value.call( this, i, old ) ); // 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 // Run tests that need a body at doc ready
jQuery(function() { jQuery(function() {
var container, div, tds, marginDiv, 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]; body = document.getElementsByTagName("body")[0];
if ( !body ) { if ( !body ) {

View File

@ -132,9 +132,7 @@ jQuery.fn.extend({
jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ), jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
all = jQuery.merge( this.get(), set ); all = jQuery.merge( this.get(), set );
return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ? return this.pushStack( jQuery.unique(all) );
all :
jQuery.unique( all ) );
}, },
addBack: function( selector ) { 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

@ -2725,4 +2725,38 @@ if ( jQuery.ajax && ( !isLocal || hasPHP ) ) {
expect( 1 ); expect( 1 );
ok( jQuery.active === 0, "ajax active counter should be zero: " + jQuery.active ); 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();
});
});
} }

View File

@ -1,7 +1,16 @@
module("attributes", { teardown: moduleTeardown }); module( "attributes", {
teardown: moduleTeardown
});
var bareObj = function( value ) { return value; }; var bareObj = function( value ) {
var functionReturningObj = function( value ) { return (function() { return value; }); }; return value;
};
var functionReturningObj = function( value ) {
return (function() {
return value;
});
};
/* /*
======== local reference ======= ======== local reference =======
@ -78,7 +87,10 @@ test("attr(String)", function() {
equal( jQuery("#area1").attr("maxLength"), "30", "Check for maxLength attribute" ); equal( jQuery("#area1").attr("maxLength"), "30", "Check for maxLength attribute" );
// using innerHTML in IE causes href attribute to be serialized to the full path // using innerHTML in IE causes href attribute to be serialized to the full path
jQuery("<a/>").attr({ "id": "tAnchor5", "href": "#5" }).appendTo("#qunit-fixture"); jQuery("<a/>").attr({
"id": "tAnchor5",
"href": "#5"
}).appendTo("#qunit-fixture");
equal( jQuery("#tAnchor5").attr("href"), "#5", "Check for non-absolute href (an anchor)" ); equal( jQuery("#tAnchor5").attr("href"), "#5", "Check for non-absolute href (an anchor)" );
// list attribute is readonly by default in browsers that support it // list attribute is readonly by default in browsers that support it
@ -98,7 +110,10 @@ test("attr(String)", function() {
body.removeAttribute("foo"); // Cleanup body.removeAttribute("foo"); // Cleanup
var select = document.createElement("select"), optgroup = document.createElement("optgroup"), option = document.createElement("option"); var select = document.createElement("select"),
optgroup = document.createElement("optgroup"),
option = document.createElement("option");
optgroup.appendChild( option ); optgroup.appendChild( option );
select.appendChild( optgroup ); select.appendChild( optgroup );
@ -148,21 +163,56 @@ test("attr(String) in XML Files", function() {
test( "attr(String, Function)", function() { test( "attr(String, Function)", function() {
expect( 2 ); expect( 2 );
equal( jQuery("#text1").attr("value", function() { return this.id; })[0].value, "text1", "Set value from id" );
equal( jQuery("#text1").attr("title", function(i) { return i; }).attr("title"), "0", "Set value with an index"); equal(
jQuery("#text1").attr( "value", function() {
return this.id;
})[0].value,
"text1",
"Set value from id"
);
equal(
jQuery("#text1").attr( "title", function(i) {
return i;
}).attr("title"),
"0",
"Set value with an index"
);
}); });
test( "attr(Hash)", function() { test( "attr(Hash)", function() {
expect( 3 ); expect( 3 );
var pass = true; var pass = true;
jQuery("div").attr({"foo": "baz", "zoo": "ping"}).each(function(){ jQuery("div").attr({
"foo": "baz",
"zoo": "ping"
}).each(function() {
if ( this.getAttribute("foo") != "baz" && this.getAttribute("zoo") != "ping" ) { if ( this.getAttribute("foo") != "baz" && this.getAttribute("zoo") != "ping" ) {
pass = false; pass = false;
} }
}); });
ok( pass, "Set Multiple Attributes" ); ok( pass, "Set Multiple Attributes" );
equal( jQuery("#text1").attr({"value": function() { return this["id"]; }})[0].value, "text1", "Set attribute to computed value #1" );
equal( jQuery("#text1").attr({"title": function(i) { return i; }}).attr("title"), "0", "Set attribute to computed value #2"); equal(
jQuery("#text1").attr({
"value": function() {
return this["id"];
}})[0].value,
"text1",
"Set attribute to computed value #1"
);
equal(
jQuery("#text1").attr({
"title": function(i) {
return i;
}
}).attr("title"),
"0",
"Set attribute to computed value #2"
);
}); });
test( "attr(String, Object)", function() { test( "attr(String, Object)", function() {
@ -180,13 +230,21 @@ test("attr(String, Object)", function() {
equal( fail, false, "Set Attribute, the #" + fail + " element didn't get the attribute 'foo'" ); equal( fail, false, "Set Attribute, the #" + fail + " element didn't get the attribute 'foo'" );
ok( jQuery("#foo").attr({ "width": null }), "Try to set an attribute to nothing" ); ok(
jQuery("#foo").attr({
"width": null
}),
"Try to set an attribute to nothing"
);
jQuery("#name").attr( "name", "something" ); jQuery("#name").attr( "name", "something" );
equal( jQuery("#name").attr("name"), "something", "Set name attribute" ); equal( jQuery("#name").attr("name"), "something", "Set name attribute" );
jQuery("#name").attr( "name", null ); jQuery("#name").attr( "name", null );
equal( jQuery("#name").attr("name"), undefined, "Remove name attribute" ); equal( jQuery("#name").attr("name"), undefined, "Remove name attribute" );
var $input = jQuery("<input>", { name: "something", id: "specified" }); var $input = jQuery( "<input>", {
name: "something",
id: "specified"
});
equal( $input.attr("name"), "something", "Check element creation gets/sets the name attribute." ); equal( $input.attr("name"), "something", "Check element creation gets/sets the name attribute." );
equal( $input.attr("id"), "specified", "Check element creation gets/sets the id attribute." ); equal( $input.attr("id"), "specified", "Check element creation gets/sets the id attribute." );
@ -298,7 +356,7 @@ test("attr(String, Object)", function() {
// for #1070 // for #1070
jQuery("#name").attr( "someAttr", "0" ); jQuery("#name").attr( "someAttr", "0" );
equal( jQuery("#name").attr("someAttr"), "0", "Set attribute to a string of \"0\"" ); equal( jQuery("#name").attr("someAttr"), "0", "Set attribute to a string of '0'" );
jQuery("#name").attr( "someAttr", 0 ); jQuery("#name").attr( "someAttr", 0 );
equal( jQuery("#name").attr("someAttr"), "0", "Set attribute to the number 0" ); equal( jQuery("#name").attr("someAttr"), "0", "Set attribute to the number 0" );
jQuery("#name").attr( "someAttr", 1 ); jQuery("#name").attr( "someAttr", 1 );
@ -352,7 +410,10 @@ test("attr(String, Object)", function() {
ok( thrown, "Exception thrown when trying to change type property" ); ok( thrown, "Exception thrown when trying to change type property" );
equal( "button", button.attr("type"), "Verify that you can't change the type of a button element" ); equal( "button", button.attr("type"), "Verify that you can't change the type of a button element" );
var $radio = jQuery("<input>", { "value": "sup", "type": "radio" }).appendTo("#testForm"); var $radio = jQuery( "<input>", {
"value": "sup",
"type": "radio"
}).appendTo("#testForm");
equal( $radio.val(), "sup", "Value is not reset when type is set after value on a radio" ); equal( $radio.val(), "sup", "Value is not reset when type is set after value on a radio" );
// Setting attributes on svg elements (bug #3116) // Setting attributes on svg elements (bug #3116)
@ -386,21 +447,31 @@ test("attr(jquery_method)", function(){
if ( jQuery.fn.offset ) { if ( jQuery.fn.offset ) {
expected += 2; expected += 2;
attrObj["offset"] = { "top": 1, "left": 0 }; attrObj["offset"] = {
"top": 1,
"left": 0
};
} }
if ( jQuery.css ) { if ( jQuery.css ) {
expected += 3; expected += 3;
attrObj["css"] = { "paddingLeft": 1, "paddingRight": 1 }; attrObj["css"] = {
"paddingLeft": 1,
"paddingRight": 1
};
} }
expect( expected ); expect( expected );
// one at a time // one at a time
$elem.attr( { "html": "foo" }, true ); $elem.attr({
"html": "foo"
}, true );
equal( elem.innerHTML, "foo", "attr(html)" ); equal( elem.innerHTML, "foo", "attr(html)" );
$elem.attr( { "text": "bar" }, true ); $elem.attr({
"text": "bar"
}, true );
equal( elem.innerHTML, "bar", "attr(text)" ); equal( elem.innerHTML, "bar", "attr(text)" );
// Multiple attributes // Multiple attributes
@ -409,14 +480,21 @@ test("attr(jquery_method)", function(){
if ( jQuery.fn.width ) { if ( jQuery.fn.width ) {
equal( elem.style.width, "10px", "attr({width:})" ); equal( elem.style.width, "10px", "attr({width:})" );
$elem.attr( { "height": 10 }, true ); $elem.attr( {
"height": 10
}, true );
equal( elem.style.height, "10px", "attr(height)" ); equal( elem.style.height, "10px", "attr(height)" );
} }
if ( jQuery.fn.offset ) { if ( jQuery.fn.offset ) {
equal( elem.style.top, "1px", "attr({offset:})" ); equal( elem.style.top, "1px", "attr({offset:})" );
$elem.attr( { offset: { top: 1, left: 1 } }, true ); $elem.attr({
offset: {
top: 1,
left: 1
}
}, true );
equal( elem.style.left, "1px", "attr(offset)" ); equal( elem.style.left, "1px", "attr(offset)" );
} }
@ -424,7 +502,11 @@ test("attr(jquery_method)", function(){
equal( elem.style.paddingLeft, "1px", "attr({css:})" ); equal( elem.style.paddingLeft, "1px", "attr({css:})" );
equal( elem.style.paddingRight, "1px", "attr({css:})" ); equal( elem.style.paddingRight, "1px", "attr({css:})" );
$elem.attr( { "css": { "color": "red" } }, true ); $elem.attr({
"css": {
"color": "red"
}
}, true );
ok( /^(#ff0000|red)$/i.test( elem.style.color ), "attr(css)" ); ok( /^(#ff0000|red)$/i.test( elem.style.color ), "attr(css)" );
} }
}); });
@ -609,7 +691,10 @@ test("prop(String, Object)", function() {
body["foo"] = undefined; body["foo"] = undefined;
ok( $body.prop("foo") === undefined, "Make sure the expando is preferred over the dom attribute, even if undefined" ); ok( $body.prop("foo") === undefined, "Make sure the expando is preferred over the dom attribute, even if undefined" );
var select = document.createElement("select"), optgroup = document.createElement("optgroup"), option = document.createElement("option"); var select = document.createElement("select"),
optgroup = document.createElement("optgroup"),
option = document.createElement("option");
optgroup.appendChild( option ); optgroup.appendChild( option );
select.appendChild( optgroup ); select.appendChild( optgroup );
@ -656,8 +741,8 @@ test("prop('tabindex')", function() {
test( "prop('tabindex', value)", 10, function() { test( "prop('tabindex', value)", 10, function() {
var element = jQuery("#divWithNoTabIndex"), var clone,
clone; element = jQuery("#divWithNoTabIndex");
equal( element.prop("tabindex"), undefined, "start with no tabindex" ); equal( element.prop("tabindex"), undefined, "start with no tabindex" );
@ -703,7 +788,11 @@ test("removeProp(String)", function() {
textNode = document.createTextNode("some text"), textNode = document.createTextNode("some text"),
obj = {}; obj = {};
strictEqual( jQuery( "#firstp" ).prop( "nonexisting", "foo" ).removeProp( "nonexisting" )[0]["nonexisting"], undefined, "removeprop works correctly on DOM element nodes" ); strictEqual(
jQuery( "#firstp" ).prop( "nonexisting", "foo" ).removeProp( "nonexisting" )[ 0 ]["nonexisting"],
undefined,
"removeprop works correctly on DOM element nodes"
);
jQuery.each( [ document, obj ], function( i, ele ) { jQuery.each( [ document, obj ], function( i, ele ) {
var $ele = jQuery( ele ); var $ele = jQuery( ele );
@ -730,9 +819,9 @@ test("val()", function() {
equal( jQuery("#first").val(), "", "Check a paragraph element to see if it has a value" ); equal( jQuery("#first").val(), "", "Check a paragraph element to see if it has a value" );
ok( jQuery([]).val() === undefined, "Check an empty jQuery object will return undefined from val" ); ok( jQuery([]).val() === undefined, "Check an empty jQuery object will return undefined from val" );
equal( jQuery("#select2").val(), "3", "Call val() on a single=\"single\" select" ); equal( jQuery("#select2").val(), "3", "Call val() on a single='single' select" );
deepEqual( jQuery("#select3").val(), ["1", "2"], "Call val() on a multiple=\"multiple\" select" ); deepEqual( jQuery("#select3").val(), [ "1", "2" ], "Call val() on a multiple='multiple' select" );
equal( jQuery("#option3c").val(), "2", "Call val() on a option element with value" ); equal( jQuery("#option3c").val(), "2", "Call val() on a option element with value" );
@ -743,15 +832,15 @@ test("val()", function() {
equal( jQuery("#option3a").val(), "", "Call val() on a option element with no value attribute" ); equal( jQuery("#option3a").val(), "", "Call val() on a option element with no value attribute" );
jQuery("#select3").val(""); jQuery("#select3").val("");
deepEqual( jQuery("#select3").val(), [""], "Call val() on a multiple=\"multiple\" select" ); deepEqual( jQuery("#select3").val(), [""], "Call val() on a multiple='multiple' select" );
deepEqual( jQuery("#select4").val(), [], "Call val() on multiple=\"multiple\" select with all disabled options" ); deepEqual( jQuery("#select4").val(), [], "Call val() on multiple='multiple' select with all disabled options" );
jQuery("#select4 optgroup").add("#select4 > [disabled]").attr( "disabled", false ); jQuery("#select4 optgroup").add("#select4 > [disabled]").attr( "disabled", false );
deepEqual( jQuery("#select4").val(), ["2", "3"], "Call val() on multiple=\"multiple\" select with some disabled options" ); deepEqual( jQuery("#select4").val(), [ "2", "3" ], "Call val() on multiple='multiple' select with some disabled options" );
jQuery("#select4").attr( "disabled", true ); jQuery("#select4").attr( "disabled", true );
deepEqual( jQuery("#select4").val(), ["2", "3"], "Call val() on disabled multiple=\"multiple\" select" ); deepEqual( jQuery("#select4").val(), [ "2", "3" ], "Call val() on disabled multiple='multiple' select" );
equal( jQuery("#select5").val(), "3", "Check value on ambiguous select." ); equal( jQuery("#select5").val(), "3", "Check value on ambiguous select." );
@ -940,7 +1029,7 @@ test("val(select) after form.reset() (Bug #2551)", function() {
equal( jQuery("#kkk").val(), "cf", "Check value of select after form reset." ); equal( jQuery("#kkk").val(), "cf", "Check value of select after form reset." );
// re-verify the multi-select is not broken (after form.reset) by our fix for single-select // re-verify the multi-select is not broken (after form.reset) by our fix for single-select
deepEqual( jQuery("#select3").val(), ["1", "2"], "Call val() on a multiple=\"multiple\" select" ); deepEqual( jQuery("#select3").val(), ["1", "2"], "Call val() on a multiple='multiple' select" );
jQuery("#kk").remove(); jQuery("#kk").remove();
}); });
@ -1000,7 +1089,8 @@ test("addClass(Function)", function() {
test( "addClass(Function) with incoming value", function() { test( "addClass(Function) with incoming value", function() {
expect( 48 ); expect( 48 );
var div = jQuery("div"), old = div.map(function(){ var div = jQuery("div"),
old = div.map(function() {
return jQuery(this).attr("class") || ""; return jQuery(this).attr("class") || "";
}); });
@ -1148,7 +1238,7 @@ var testToggleClass = function(valueObj) {
// Cleanup // Cleanup
e.removeClass("testD"); e.removeClass("testD");
jQuery.removeData(e[0], "__className__", true); jQuery._removeData( e[ 0 ], "__className__" );
}; };
test( "toggleClass(String|boolean|undefined[, boolean])", function() { test( "toggleClass(String|boolean|undefined[, boolean])", function() {
@ -1209,7 +1299,7 @@ test("toggleClass(Fucntion[, boolean]) with incoming value", function() {
// Cleanup // Cleanup
e.removeClass("test"); e.removeClass("test");
jQuery.removeData(e[0], "__className__", true); jQuery._removeData( e[ 0 ], "__className__" );
}); });
test( "addClass, removeClass, hasClass", function() { test( "addClass, removeClass, hasClass", function() {
@ -1266,8 +1356,8 @@ test("contents().hasClass() returns correct values", function() {
test( "coords returns correct values in IE6/IE7, see #10828", function() { test( "coords returns correct values in IE6/IE7, see #10828", function() {
expect( 2 ); expect( 2 );
var map = jQuery("<map />"), var area,
area; map = jQuery("<map />");
area = map.html("<area shape='rect' coords='0,0,0,0' href='#' alt='a' />").find("area"); area = map.html("<area shape='rect' coords='0,0,0,0' href='#' alt='a' />").find("area");
equal( area.attr("coords"), "0,0,0,0", "did not retrieve coords correctly" ); equal( area.attr("coords"), "0,0,0,0", "did not retrieve coords correctly" );

View File

@ -107,4 +107,33 @@ if ( jQuery.browser ) {
ok(!!jQuery.attrFn, "attrFnPresent"); 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." ); 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() { 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." ); 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() { test("height()", function() {
@ -156,7 +156,7 @@ test("innerWidth()", function() {
equal( div.innerWidth(), 0, "Make sure that disconnected nodes are handled." ); equal( div.innerWidth(), 0, "Make sure that disconnected nodes are handled." );
div.remove(); div.remove();
jQuery.removeData($div[0], "olddisplay", true); jQuery._removeData( $div[0], "olddisplay" );
}); });
test("innerHeight()", function() { test("innerHeight()", function() {
@ -191,7 +191,7 @@ test("innerHeight()", function() {
equal( div.innerHeight(), 0, "Make sure that disconnected nodes are handled." ); equal( div.innerHeight(), 0, "Make sure that disconnected nodes are handled." );
div.remove(); div.remove();
jQuery.removeData($div[0], "olddisplay", true); jQuery._removeData( $div[0], "olddisplay" );
}); });
test("outerWidth()", function() { test("outerWidth()", function() {
@ -229,7 +229,7 @@ test("outerWidth()", function() {
equal( div.outerWidth(), 0, "Make sure that disconnected nodes are handled." ); equal( div.outerWidth(), 0, "Make sure that disconnected nodes are handled." );
div.remove(); 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() { 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." ); equal( div.outerHeight(), 0, "Make sure that disconnected nodes are handled." );
div.remove(); div.remove();
jQuery.removeData($div[0], "olddisplay", true); jQuery._removeData( $div[0], "olddisplay" );
}); });
test("passing undefined is a setter #5571", function() { test("passing undefined is a setter #5571", function() {

View File

@ -1014,7 +1014,7 @@ jQuery.checkState = function() {
}); });
// manually clean data on modified element // manually clean data on modified element
jQuery.removeData( this, "olddisplay", true ); jQuery._removeData( this, "olddisplay" );
start(); 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." ); 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 // Remove olddisplay data from .hide() call
jQuery.removeData( this, "olddisplay", true ); jQuery._removeData( this, "olddisplay" );
start(); start();
}); });
}, animTime / 2); }, animTime / 2);
@ -1498,7 +1498,7 @@ test( "animate should set display for disconnected nodes", function() {
// cleanup // cleanup
jQuery.each( elems, function() { jQuery.each( elems, function() {
jQuery.removeData( this[ 0 ], "olddisplay", true ); jQuery._removeData( this[ 0 ], "olddisplay" );
}); });
stop(); stop();
@ -1515,7 +1515,7 @@ test( "animate should set display for disconnected nodes", function() {
var callback = [function () { var callback = [function () {
strictEqual( this.style.display, "block", "set display to block with " + name ); strictEqual( this.style.display, "block", "set display to block with " + name );
jQuery.removeData( this, "olddisplay", true ); jQuery._removeData( this, "olddisplay" );
if ( ++i === 14 ) { if ( ++i === 14 ) {
start(); start();

View File

@ -798,8 +798,8 @@ test("unbind(eventObject)", function() {
assert( 0 ); assert( 0 );
}); });
test("hover() and hover pseudo-event", function() { test("hover() mouseenter mouseleave", function() {
expect(3); expect(1);
var times = 0, var times = 0,
handler1 = function( event ) { ++times; }, handler1 = function( event ) { ++times; },
@ -817,30 +817,6 @@ test("hover() and hover pseudo-event", function() {
equal( times, 4, "hover handlers fired" ); 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() { 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() { div.promise("fx").done(function() {
equal(counter, 4, "Deferreds resolved"); equal(counter, 4, "Deferreds resolved");
jQuery.removeData( div[0], "olddisplay", true ); jQuery._removeData( div[0], "olddisplay" );
start(); 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" ); 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() { (function() {
var userAgent = window.navigator.userAgent, var userAgent = window.navigator.userAgent,

View File

@ -582,7 +582,7 @@ test("contents()", function() {
}); });
test("add(String|Element|Array|undefined)", 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("#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" ); 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()" ); //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"); var divs = jQuery("<div/>").add("#sndp");
ok( !divs[0].parentNode, "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("<div>test</div>").add("#sndp");
equal( divs[0].parentNode.nodeType, 11, "Make sure the first element is still the disconnected node." );
divs = jQuery("#sndp").add("<div/>"); 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/>"); var tmp = jQuery("<div/>");