diff --git a/AUTHORS.txt b/AUTHORS.txt new file mode 100644 index 000000000..51200abaf --- /dev/null +++ b/AUTHORS.txt @@ -0,0 +1,132 @@ +Authors ordered by first contribution. + +John Resig +Gilles van den Hoven +Michael Geary +Stefan Petre +Yehuda Katz +Corey Jewett +Klaus Hartl +Franck Marcia +Jörn Zaefferer +Paul Bakaus +Brandon Aaron +Mike Alsup +Dave Methvin +Ed Engelhardt +Sean Catchpole +Paul Mclanahan +David Serduke +Richard D. Worth +Scott González +Ariel Flesler +Jon Evans +T.J. Holowaychuk +Michael Bensoussan +Robert Katić +Louis-Rémi Babé +Earle Castledine +Damian Janowski +Rich Dougherty +Kim Dalsgaard +Andrea Giammarchi +Mark Gibson +Karl Swedberg +Justin Meyer +Ben Alman +James Padolsey +David Petersen +Batiste Bieler +Alexander Farkas +Rick Waldron +Filipe Fortes +Neeraj Singh +Paul Irish +Iraê Carvalho +Matt Curry +Michael Monteleone +Noah Sloan +Tom Viner +Douglas Neiner +Adam J. Sontag +Dave Reed +Ralph Whitbeck +Carl Fürstenberg +Jacob Wright +J. Ryan Stinnett +Heungsub Lee +Colin Snover +Ryan W Tenney +R.J.G. Otten +Jephte Clain +Anton Matzneller +Alex Sexton +Dan Heberden +Henri Wiechers +Russell Holbrook +Julian Aubourg +Gianni Chiappetta +Scott Jehl +J.R. Burke +Jonas Pfenniger +Xavi Ramirez +Jared Grippe +Sylvester Keil +Brandon Sterne +Mathias Bynens +Timmy Willison +Corey Frang +Anton Kovalyov +David Murdoch +Josh Varner +Charles McNulty +Jordan Boesch +Jess Thrysoee +Michael Murray +Lee Carpenter +Alexis Abril +Rob Morgan +John Firebaugh +Sam Bisbee +Gilmore Davidson +Brian Brennan +Xavier Montillet +Daniel Pihlstrom +Sahab Yazdani +Scott Hughes +Mike Sherov +Greg Hazel +Schalk Neethling +Denis Knauf +Timo Tijhof +Steen Nielsen +Anton Ryzhov +Shi Chuan +Berker Peksag +Toby Brain +Matt Mueller +Daniel Herman +Oleg Gaidarenko +Richard Gibson +Rafaël Blais Masson +Joe Presbrey +Sindre Sorhus +Arne de Bree +Vladislav Zarakovsky +Andy Monat +Joaoh Bruni +Dominik D. Geyer +Matt Farmer +Trey Hunner +Jason Moon +Jeffery To +Kris Borchers +Vladimir Zhuravlev +Jacob Thornton +Chad Killingsworth +Nowres Rafid +David Benjamin +Uri Gilad +Chris Faulkner +Elijah Manor +Daniel Chatfield diff --git a/grunt.js b/grunt.js index 02a688162..61b7b4e4b 100644 --- a/grunt.js +++ b/grunt.js @@ -121,8 +121,9 @@ module.exports = function( grunt ) { // Short list as a high frequency watch task grunt.registerTask( "dev", "selector build:*:* lint" ); - // Load the "compare_size" task from NPM packages + // Load grunt tasks from NPM packages grunt.loadNpmTasks( "grunt-compare-size" ); + grunt.loadNpmTasks( "grunt-git-authors" ); grunt.registerTask( "testswarm", function( commit, configFile ) { var testswarm = require( "testswarm" ), diff --git a/package.json b/package.json index ecebd2cc2..3ac92df77 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "dependencies": {}, "devDependencies": { "grunt-compare-size": ">=0.1.0", + "grunt-git-authors": ">=1.0.0", "grunt": "~0.3.9", "testswarm": "0.2.2" }, diff --git a/src/ajax.js b/src/ajax.js index 304a41d48..f3887ff44 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -861,7 +861,7 @@ function ajaxConvert( s, response ) { if ( conv !== true ) { // Unless errors are allowed to bubble, catch and return them - if ( conv && s.throws ) { + if ( conv && s["throws"] ) { response = conv( response ); } else { try { diff --git a/src/css.js b/src/css.js index 0b20b7c4c..dcba720e5 100644 --- a/src/css.js +++ b/src/css.js @@ -43,6 +43,11 @@ function vendorPropName( style, name ) { return origName; } +function isHidden( elem, el ) { + elem = el || elem; + return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem ); +} + function showHide( elements, show ) { var elem, display, values = [], @@ -65,8 +70,7 @@ function showHide( elements, show ) { // Set elements which have been overridden with display: none // in a stylesheet to whatever the default browser style is // for such an element - if ( (elem.style.display === "" && curCSS( elem, "display" ) === "none") || - !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) { + if ( elem.style.display === "" && isHidden( elem ) ) { values[ index ] = jQuery._data( elem, "olddisplay", css_defaultDisplay(elem.nodeName) ); } } else { @@ -107,16 +111,19 @@ jQuery.fn.extend({ hide: function() { return showHide( this ); }, - toggle: function( fn, fn2 ) { - var bool = typeof fn === "boolean"; + toggle: function( state, fn2 ) { + var bool = typeof state === "boolean"; - if ( jQuery.isFunction( fn ) && jQuery.isFunction( fn2 ) ) { + if ( jQuery.isFunction( state ) && jQuery.isFunction( fn2 ) ) { return eventsToggle.apply( this, arguments ); } return this.each(function() { - var state = bool ? fn : jQuery( this ).is(":hidden"); - showHide([ this ], state ); + if ( bool ? state : isHidden( this ) ) { + jQuery( this ).show(); + } else { + jQuery( this ).hide(); + } }); } }); @@ -290,7 +297,7 @@ if ( window.getComputedStyle ) { // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values - if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) { + if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) { width = style.width; minWidth = style.minWidth; maxWidth = style.maxWidth; diff --git a/src/data.js b/src/data.js index c7de049a2..f51a3e520 100644 --- a/src/data.js +++ b/src/data.js @@ -304,8 +304,9 @@ function dataAttr( elem, key, data ) { data = data === "true" ? true : data === "false" ? false : data === "null" ? null : - jQuery.isNumeric( data ) ? +data : - rbrace.test( data ) ? jQuery.parseJSON( data ) : + // Only convert to a number if it doesn't change the string + +data + "" === data ? +data : + rbrace.test( data ) ? jQuery.parseJSON( data ) : data; } catch( e ) {} diff --git a/src/effects.js b/src/effects.js index dbca88650..3405cfdc2 100644 --- a/src/effects.js +++ b/src/effects.js @@ -437,11 +437,6 @@ Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = { } }; -function isHidden( elem, el ) { - elem = el || elem; - return curCSS( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument.documentElement, elem ); -} - jQuery.each([ "toggle", "show", "hide" ], function( i, name ) { var cssFn = jQuery.fn[ name ]; jQuery.fn[ name ] = function( speed, easing, callback ) { diff --git a/src/manipulation.js b/src/manipulation.js index b755b2f1c..3cfc97c3b 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -362,7 +362,7 @@ jQuery.fn.extend({ dataType: "script", async: false, global: false, - throws: true + "throws": true }); } else { jQuery.error("no ajax"); @@ -436,14 +436,9 @@ function cloneFixAttributes( src, dest ) { nodeName = dest.nodeName.toLowerCase(); - // IE6-8 fail to clone children inside object elements that use - // the proprietary classid attribute value (rather than the type - // attribute) to identify the type of content to display if ( nodeName === "object" ) { - // The official HTML5 specs read that a NO_MODIFICATION_ALLOWED_ERR - // needs to be thrown if the parent is a Document - // http://html5.org/specs/dom-parsing.html#dom-element-outerhtml - // IE10 throws NoModificationAllowedError if parent node is null + // IE6-10 improperly clones children of object elements using classid. + // IE10 throws NoModificationAllowedError if parent is null, #12132. if ( dest.parentNode ) { dest.outerHTML = src.outerHTML; } @@ -460,9 +455,8 @@ function cloneFixAttributes( src, dest ) { // IE6-8 fails to persist the checked state of a cloned checkbox // or radio button. Worse, IE6-7 fail to give the cloned element // a checked appearance if the defaultChecked value isn't also set - if ( src.checked ) { - dest.defaultChecked = dest.checked = src.checked; - } + + dest.defaultChecked = dest.checked = src.checked; // IE6-7 get confused and end up setting the value of a cloned // checkbox/radio button to an empty string instead of "on" diff --git a/src/sizzle b/src/sizzle index 6e524a591..a0523a509 160000 --- a/src/sizzle +++ b/src/sizzle @@ -1 +1 @@ -Subproject commit 6e524a5915a8a5dda1969898749c81d0fae64e6e +Subproject commit a0523a50942971b41af6aba39b39ee81c1fc5f8a diff --git a/src/traversing.js b/src/traversing.js index 321c25197..4c58ae0b8 100644 --- a/src/traversing.js +++ b/src/traversing.js @@ -48,12 +48,12 @@ jQuery.fn.extend({ }, has: function( target ) { - var i = 0, + var i, targets = jQuery( target, this ), - l = targets.length; + len = targets.length; return this.filter(function() { - for ( ; i < l; i++ ) { + for ( i = 0; i < len; i++ ) { if ( jQuery.contains( this, targets[i] ) ) { return true; } @@ -92,17 +92,12 @@ jQuery.fn.extend({ for ( ; i < l; i++ ) { cur = this[i]; - while ( cur ) { + while ( cur && cur.ownerDocument && cur !== context && cur.nodeType !== 11 ) { if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) { ret.push( cur ); break; - - } else { - cur = cur.parentNode; - if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) { - break; - } } + cur = cur.parentNode; } } diff --git a/test/unit/ajax.js b/test/unit/ajax.js index 85069b482..2371f8982 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -2153,7 +2153,7 @@ test( "jQuery.ajax - statusText" , 3, function() { stop(); jQuery.ajax( url( "data/statusText.php?status=200&text=Hello" ) ).done(function( _, statusText, jqXHR ) { strictEqual( statusText, "success", "callback status text ok for success" ); - ok( jqXHR.statusText === "Hello" || jQuery.browser.safari && jqXHR.statusText === "OK", "jqXHR status text ok for success (" + jqXHR.statusText + ")" ); + ok( jqXHR.statusText === "Hello" || jqXHR.statusText === "OK", "jqXHR status text ok for success (" + jqXHR.statusText + ")" ); jQuery.ajax( url( "data/statusText.php?status=404&text=World" ) ).fail(function( jqXHR, statusText ) { strictEqual( statusText, "error", "callback status text ok for error" ); // ok( jqXHR.statusText === "World" || jQuery.browser.safari && jqXHR.statusText === "Not Found", "jqXHR status text ok for error (" + jqXHR.statusText + ")" ); diff --git a/test/unit/css.js b/test/unit/css.js index 45aee9f06..dca5a08e0 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -561,8 +561,10 @@ test( "show() resolves correct default display, detached nodes (#10006)", functi }); test("toggle()", function() { - expect(6); - var x = jQuery("#foo"); + expect(9); + var div, + x = jQuery("#foo"); + ok( x.is(":visible"), "is visible" ); x.toggle(); ok( x.is(":hidden"), "is hidden" ); @@ -575,6 +577,20 @@ test("toggle()", function() { ok( x.is(":hidden"), "is hidden" ); x.toggle(true); ok( x.is(":visible"), "is visible again" ); + + div = jQuery("
").appendTo("#qunit-fixture"); + x = div.find("div"); + strictEqual( x.toggle().css( "display" ), "none", "is hidden" ); + strictEqual( x.toggle().css( "display" ), "block", "is visible" ); + + // Ensure hide() is called when toggled (#12148) + var oldHide = jQuery.fn.hide; + jQuery.fn.hide = function() { + ok( true, name + " method called on toggle" ); + return oldHide.apply( this, arguments ); + }; + x.toggle( name === "show" ); + jQuery.fn.hide = oldHide; }); test("hide hidden elements (bug #7141)", function() { diff --git a/test/unit/data.js b/test/unit/data.js index 3083a947d..7f4ad6c36 100644 --- a/test/unit/data.js +++ b/test/unit/data.js @@ -294,7 +294,7 @@ test(".data(String) and .data(String, Object)", function() { }); test("data-* attributes", function() { - expect(38); + expect(40); var div = jQuery("
"), child = jQuery("
"), dummy = jQuery("
"); @@ -357,9 +357,11 @@ test("data-* attributes", function() { .attr("data-five", "5") .attr("data-point", "5.5") .attr("data-pointe", "5.5E3") + .attr("data-grande", "5.574E9") .attr("data-hexadecimal", "0x42") .attr("data-pointbad", "5..5") .attr("data-pointbad2", "-.") + .attr("data-bigassnum", "123456789123456789123456789") .attr("data-badjson", "{123}") .attr("data-badjson2", "[abc]") .attr("data-empty", "") @@ -371,10 +373,12 @@ test("data-* attributes", function() { strictEqual( child.data("false"), false, "Primitive false read from attribute"); strictEqual( child.data("five"), 5, "Primitive number read from attribute"); strictEqual( child.data("point"), 5.5, "Primitive number read from attribute"); - strictEqual( child.data("pointe"), 5500, "Primitive number read from attribute"); - strictEqual( child.data("hexadecimal"), 66, "Hexadecimal number read from attribute"); + strictEqual( child.data("pointe"), "5.5E3", "Floating point exponential number read from attribute"); + strictEqual( child.data("grande"), "5.574E9", "Big exponential number read from attribute"); + strictEqual( child.data("hexadecimal"), "0x42", "Hexadecimal number read from attribute"); strictEqual( child.data("pointbad"), "5..5", "Bad number read from attribute"); strictEqual( child.data("pointbad2"), "-.", "Bad number read from attribute"); + strictEqual( child.data("bigassnum"), "123456789123456789123456789", "Bad bigass number read from attribute"); strictEqual( child.data("badjson"), "{123}", "Bad number read from attribute"); strictEqual( child.data("badjson2"), "[abc]", "Bad number read from attribute"); strictEqual( child.data("empty"), "", "Empty string read from attribute"); diff --git a/test/unit/effects.js b/test/unit/effects.js index 17ba1c21a..4353e1566 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -598,7 +598,7 @@ test("stop() - several in queue", function() { var w = 0; $foo.hide().css( "width", 200 ).css("width"); - $foo.animate({ "width": "show" }, 1000); + $foo.animate({ "width": "show" }, 1500); $foo.animate({ "width": "hide" }, 1000); $foo.animate({ "width": "show" }, 1000); setTimeout(function(){ @@ -612,7 +612,7 @@ test("stop() - several in queue", function() { $foo.stop(true); start(); - }, 100); + }, 200); }); test("stop(clearQueue)", function() { @@ -1413,7 +1413,9 @@ asyncTest( "Animate Option: step: function( percent, tween )", 1, function() { duration: 1, step: function( value, tween ) { var calls = counter[ tween.prop ] = counter[ tween.prop ] || []; - calls.push( value ); + // in case this is called multiple times for either, lets store it in + // 0 or 1 in the array + calls[ value === 0 ? 0 : 1 ] = value; } }).queue( function( next ) { deepEqual( counter, { @@ -1768,6 +1770,10 @@ asyncTest("Animation callbacks (#11797)", 15, function() { ok( true, "async: start" ); }, progress: function( anim, percent ) { + // occasionally the progress handler is called twice in first frame.... *shrug* + if ( percent === 0 && expectedProgress === 1 ) { + return; + } equal( percent, expectedProgress, "async: progress " + expectedProgress ); // once at 0, once at 1 expectedProgress++; diff --git a/test/unit/event.js b/test/unit/event.js index dacb03355..ecaddf3a4 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -2344,7 +2344,7 @@ test("jQuery.off using dispatched jQuery.Event", function() { test( "delegated event with delegateTarget-relative selector", function() { expect(2); - var markup = jQuery( '
' ).appendTo("body"); + var markup = jQuery("
").appendTo("#qunit-fixture"); markup .on( "click", ">li>a", function() { diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index 31426e739..4038f1a74 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -1895,3 +1895,15 @@ test("html() - script exceptions bubble (#11743)", function() { ok( false, "error ignored" ); }, "exception bubbled from remote script" ); }); + +test("checked state is cloned with clone()", function(){ + expect(2); + + var elem = jQuery.parseHTML("")[0]; + elem.checked = false; + equal( jQuery(elem).clone().attr("id","clone")[0].checked, false, "Checked false state correctly cloned" ); + + elem = jQuery.parseHTML("")[0]; + elem.checked = true; + equal( jQuery(elem).clone().attr("id","clone")[0].checked, true, "Checked true state correctly cloned" ); +}); diff --git a/test/unit/offset.js b/test/unit/offset.js index 6d00e8dac..d18bc4bb8 100644 --- a/test/unit/offset.js +++ b/test/unit/offset.js @@ -218,20 +218,17 @@ testIframe("offset/relative", "relative", function( $ ) { testIframe("offset/static", "static", function( $ ) { // IE is collapsing the top margin of 1px; detect and adjust accordingly - var ie = $("#static-1").offset().top === 6, - swarmy = document.documentMode === 8 && window.location.search.indexOf("swarmURL") >= 0; + var ie = $("#static-1").offset().top === 6; - expect( swarmy? 68 : 80 ); + expect( 80 ); // get offset var tests = [ { "id": "#static-1", "top": ie ? 6 : 7, "left": 7 }, { "id": "#static-1-1", "top": ie ? 13 : 15, "left": 15 }, - { "id": "#static-1-1-1", "top": ie ? 20 : 23, "left": 23 } + { "id": "#static-1-1-1", "top": ie ? 20 : 23, "left": 23 }, + { "id": "#static-2", "top": ie ? 121 : 122, left: 7 } ]; - if ( !swarmy ) { - tests.push({ "id": "#static-2", "top": ie ? 121 : 122, left: 7 }); - } jQuery.each( tests, function() { equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset().top" ); equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset().left" ); @@ -242,12 +239,9 @@ testIframe("offset/static", "static", function( $ ) { tests = [ { "id": "#static-1", "top": ie ? 5 : 6, "left": 6 }, { "id": "#static-1-1", "top": ie ? 12 : 14, "left": 14 }, - { "id": "#static-1-1-1", "top": ie ? 19 : 22, "left": 22 } - + { "id": "#static-1-1-1", "top": ie ? 19 : 22, "left": 22 }, + { "id": "#static-2", "top": ie ? 120 : 121, "left": 6 } ]; - if ( !swarmy ) { - tests.push({ "id": "#static-2", "top": ie ? 120 : 121, "left": 6 }); - } jQuery.each( tests, function() { equal( $( this["id"] ).position().top, this["top"], "jQuery('" + this["top"] + "').position().top" ); equal( $( this["id"] ).position().left, this["left"], "jQuery('" + this["left"] +"').position().left" ); @@ -269,15 +263,10 @@ testIframe("offset/static", "static", function( $ ) { { "id": "#static-1-1", "top": -3, "left": -3 }, { "id": "#static-1-1", "top": 14, "left": 14 }, { "id": "#static-1", "top": 30, "left": 30 }, - { "id": "#static-1", "top": 2, "left": 2 } - + { "id": "#static-1", "top": 2, "left": 2 }, + { "id": "#static-1", "top": -2, "left": -2 }, + { "id": "#static-1", "top": 7, "left": 7 } ]; - if ( !swarmy ) { - tests.push( - { "id": "#static-1", "top": -2, "left": -2 }, - { "id": "#static-1", "top": 7, "left": 7 } - ); - } jQuery.each( tests, function() { $( this["id"] ).offset({ "top": this["top"], "left": this["left"] }); equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset({ top: " + this["top"] + " })" ); diff --git a/test/unit/traversing.js b/test/unit/traversing.js index 2712e7f2f..e7d519662 100644 --- a/test/unit/traversing.js +++ b/test/unit/traversing.js @@ -275,7 +275,8 @@ test("filter() with positional selectors", function() { }); test("closest()", function() { - expect(13); + expect( 14 ); + deepEqual( jQuery("body").closest("body").get(), q("body"), "closest(body)" ); deepEqual( jQuery("body").closest("html").get(), q("html"), "closest(html)" ); deepEqual( jQuery("body").closest("div").get(), [], "closest(div)" ); @@ -299,6 +300,8 @@ test("closest()", function() { // Bug #7369 equal( jQuery("
").closest("[foo]").length, 1, "Disconnected nodes with attribute selector" ); equal( jQuery("
text
").closest("[lang]").length, 0, "Disconnected nodes with text and non-existent attribute selector" ); + + ok( !jQuery(document).closest("#foo").length, "Calling closest on a document fails silently" ); }); test("closest(jQuery)", function() { @@ -373,7 +376,7 @@ test("has(Element)", function() { }); test("has(Selector)", function() { - expect(4); + expect( 5 ); var obj = jQuery("#qunit-fixture").has("#sndp"); deepEqual( obj.get(), q("qunit-fixture"), "Keeps elements that have any element matching the selector as a descendant" ); @@ -382,7 +385,10 @@ test("has(Selector)", function() { deepEqual( detached.has("i").get(), detached.get(), "...Even when detached" ); var multipleParent = jQuery("#qunit-fixture, #header").has("#sndp"); - deepEqual( obj.get(), q("qunit-fixture"), "Does not include elements that do not have the element as a descendant" ); + deepEqual( multipleParent.get(), q("qunit-fixture"), "Does not include elements that do not have the element as a descendant" ); + + multipleParent = jQuery("#select1, #select2, #select3").has("#option1a, #option3a"); + deepEqual( multipleParent.get(), q("select1", "select3"), "Multiple contexts are checks correctly" ); var multipleHas = jQuery("#qunit-fixture").has("#sndp, #first"); deepEqual( multipleHas.get(), q("qunit-fixture"), "Only adds elements once" );