diff options
author | Elijah Manor <elijah.manor@gmail.com> | 2012-07-30 11:29:15 -0500 |
---|---|---|
committer | Elijah Manor <elijah.manor@gmail.com> | 2012-07-30 11:29:15 -0500 |
commit | 0d07e7fc2cf33d70ea51ae58cd0c76bf48f8b3be (patch) | |
tree | 8c49b1a0b1e499ba8d77a20cf52849c0d7baaad7 | |
parent | 039222f8bf4591807e5d25e2a2308a79f87e656d (diff) | |
parent | beeab4d126b303b194899adf579d8f43e3fd5e69 (diff) | |
download | jquery-0d07e7fc2cf33d70ea51ae58cd0c76bf48f8b3be.tar.gz jquery-0d07e7fc2cf33d70ea51ae58cd0c76bf48f8b3be.zip |
Manual merge after fetch upstream
-rw-r--r-- | AUTHORS.txt | 132 | ||||
-rw-r--r-- | grunt.js | 3 | ||||
-rw-r--r-- | package.json | 1 | ||||
-rw-r--r-- | src/ajax.js | 2 | ||||
-rw-r--r-- | src/css.js | 23 | ||||
-rw-r--r-- | src/data.js | 5 | ||||
-rw-r--r-- | src/effects.js | 5 | ||||
-rw-r--r-- | src/manipulation.js | 16 | ||||
m--------- | src/sizzle | 0 | ||||
-rw-r--r-- | src/traversing.js | 15 | ||||
-rw-r--r-- | test/unit/ajax.js | 2 | ||||
-rw-r--r-- | test/unit/css.js | 20 | ||||
-rw-r--r-- | test/unit/data.js | 10 | ||||
-rw-r--r-- | test/unit/effects.js | 12 | ||||
-rw-r--r-- | test/unit/event.js | 2 | ||||
-rw-r--r-- | test/unit/manipulation.js | 12 | ||||
-rw-r--r-- | test/unit/offset.js | 29 | ||||
-rw-r--r-- | test/unit/traversing.js | 12 |
18 files changed, 230 insertions, 71 deletions
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 <jeresig@gmail.com> +Gilles van den Hoven <gilles0181@gmail.com> +Michael Geary <mike@geary.com> +Stefan Petre <stefan.petre@gmail.com> +Yehuda Katz <wycats@gmail.com> +Corey Jewett <cj@syntheticplayground.com> +Klaus Hartl <klaus.hartl@googlemail.com> +Franck Marcia <franck.marcia@gmail.com> +Jörn Zaefferer <joern.zaefferer@gmail.com> +Paul Bakaus <paul.bakaus@googlemail.com> +Brandon Aaron <brandon.aaron@gmail.com> +Mike Alsup <malsup@gmail.com> +Dave Methvin <dave.methvin@gmail.com> +Ed Engelhardt <edengelhardt@gmail.com> +Sean Catchpole <littlecooldude@gmail.com> +Paul Mclanahan <pmclanahan@gmail.com> +David Serduke <davidserduke@gmail.com> +Richard D. Worth <rdworth@gmail.com> +Scott González <scott.gonzalez@gmail.com> +Ariel Flesler <aflesler@gmail.com> +Jon Evans <jon@springyweb.com> +T.J. Holowaychuk <tj@vision-media.ca> +Michael Bensoussan <mickey@seesmic.com> +Robert Katić <robert.katic@gmail.com> +Louis-Rémi Babé <lrbabe@gmail.com> +Earle Castledine <mrspeaker@gmail.com> +Damian Janowski <damian.janowski@gmail.com> +Rich Dougherty <rich@rd.gen.nz> +Kim Dalsgaard <kim@kimdalsgaard.com> +Andrea Giammarchi <andrea.giammarchi@gmail.com> +Mark Gibson <jollytoad@gmail.com> +Karl Swedberg <karl@englishrules.com> +Justin Meyer <justinbmeyer@gmail.com> +Ben Alman <cowboy@rj3.net> +James Padolsey <jamespadolsey@gmail.com> +David Petersen <public@petersendidit.com> +Batiste Bieler <batiste.bieler@gmail.com> +Alexander Farkas <info@corrupt-system.de> +Rick Waldron <waldron.rick@gmail.com> +Filipe Fortes <filipe@fortes.com> +Neeraj Singh <neerajdotname@gmail.com> +Paul Irish <paul.irish@gmail.com> +Iraê Carvalho <irae@irae.pro.br> +Matt Curry <matt@pseudocoder.com> +Michael Monteleone <michael@michaelmonteleone.net> +Noah Sloan <noah.sloan@gmail.com> +Tom Viner <github@viner.tv> +Douglas Neiner <doug@pixelgraphics.us> +Adam J. Sontag <ajpiano@ajpiano.com> +Dave Reed <dareed@microsoft.com> +Ralph Whitbeck <ralph.whitbeck@gmail.com> +Carl Fürstenberg <azatoth@gmail.com> +Jacob Wright <jacwright@gmail.com> +J. Ryan Stinnett <jryans@gmail.com> +Heungsub Lee <lee@heungsub.net> +Colin Snover <colin@alpha.zetafleet.com> +Ryan W Tenney <ryan@10e.us> +R.J.G. Otten <r.j.g.otten@gmail.com> +Jephte Clain <Jephte.Clain@univ-reunion.fr> +Anton Matzneller <obhvsbypqghgc@gmail.com> +Alex Sexton <AlexSexton@gmail.com> +Dan Heberden <danheberden@gmail.com> +Henri Wiechers <hwiechers@gmail.com> +Russell Holbrook <russell.holbrook@patch.com> +Julian Aubourg <aubourg.julian@gmail.com> +Gianni Chiappetta <gianni@runlevel6.org> +Scott Jehl <scott@scottjehl.com> +J.R. Burke <jrburke@gmail.com> +Jonas Pfenniger <jonas@pfenniger.name> +Xavi Ramirez <xavi.rmz@gmail.com> +Jared Grippe <jared@deadlyicon.com> +Sylvester Keil <sylvester@keil.or.at> +Brandon Sterne <bsterne@mozilla.com> +Mathias Bynens <mathias@qiwi.be> +Timmy Willison <timmywillisn@gmail.com> +Corey Frang <gnarf@gnarf.net> +Anton Kovalyov <anton@kovalyov.net> +David Murdoch <musicisair@yahoo.com> +Josh Varner <josh.varner@gmail.com> +Charles McNulty <cmcnulty@kznf.com> +Jordan Boesch <jboesch26@gmail.com> +Jess Thrysoee <jess@thrysoee.dk> +Michael Murray <mmurray.wa@gmail.com> +Lee Carpenter <elcarpie@gmail.com> +Alexis Abril <alexis.abril@gmail.com> +Rob Morgan <robbym@gmail.com> +John Firebaugh <john_firebaugh@bigfix.com> +Sam Bisbee <sam@sbisbee.com> +Gilmore Davidson <gilmoreorless@gmail.com> +Brian Brennan <me@brianlovesthings.com> +Xavier Montillet <xavierm02.net@gmail.com> +Daniel Pihlstrom <sciolist.se@gmail.com> +Sahab Yazdani <sahab.yazdani+github@gmail.com> +Scott Hughes <hi@scott-hughes.me> +Mike Sherov <mike.sherov@gmail.com> +Greg Hazel <ghazel@gmail.com> +Schalk Neethling <schalk@ossreleasefeed.com> +Denis Knauf <Denis.Knauf@gmail.com> +Timo Tijhof <krinklemail@gmail.com> +Steen Nielsen <swinedk@gmail.com> +Anton Ryzhov <anton@ryzhov.me> +Shi Chuan <shichuanr@gmail.com> +Berker Peksag <berker.peksag@gmail.com> +Toby Brain <tobyb@freshview.com> +Matt Mueller <mattmuelle@gmail.com> +Daniel Herman <daniel.c.herman@gmail.com> +Oleg Gaidarenko <markelog@gmail.com> +Richard Gibson <richard.gibson@gmail.com> +Rafaël Blais Masson <rafbmasson@gmail.com> +Joe Presbrey <presbrey@gmail.com> +Sindre Sorhus <sindresorhus@gmail.com> +Arne de Bree <arne@bukkie.nl> +Vladislav Zarakovsky <vlad.zar@gmail.com> +Andy Monat <amonat@gmail.com> +Joaoh Bruni <joaohbruni@yahoo.com.br> +Dominik D. Geyer <dominik.geyer@gmail.com> +Matt Farmer <matt@frmr.me> +Trey Hunner <treyhunner@gmail.com> +Jason Moon <jmoon@socialcast.com> +Jeffery To <jeffery.to@gmail.com> +Kris Borchers <kris.borchers@gmail.com> +Vladimir Zhuravlev <private.face@gmail.com> +Jacob Thornton <jacobthornton@gmail.com> +Chad Killingsworth <chadkillingsworth@missouristate.edu> +Nowres Rafid <nowres.rafed@gmail.com> +David Benjamin <davidben@mit.edu> +Uri Gilad <antishok@gmail.com> +Chris Faulkner <thefaulkner@gmail.com> +Elijah Manor <elijah.manor@gmail.com> +Daniel Chatfield <chatfielddaniel@googlemail.com> @@ -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 -Subproject 6e524a5915a8a5dda1969898749c81d0fae64e6 +Subproject a0523a50942971b41af6aba39b39ee81c1fc5f8 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("<div style='display:none'><div></div></div>").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("<div>"), child = jQuery("<div data-myobj='old data' data-ignored=\"DOM\" data-other='test'></div>"), dummy = jQuery("<div data-myobj='old data' data-ignored=\"DOM\" data-other='test'></div>"); @@ -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( '<ul><li><a id="a0"></a><ul id="ul0"><li><a id="a0_0"></a></li><li><a id="a0_1"></a></li></ul></li></ul>' ).appendTo("body"); + var markup = jQuery("<ul><li><a id=\"a0\"></a><ul id=\"ul0\"><li><a id=\"a0_0\"></a></li><li><a id=\"a0_1\"></a></li></ul></li></ul>").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("<input type='checkbox' checked='checked'/>")[0]; + elem.checked = false; + equal( jQuery(elem).clone().attr("id","clone")[0].checked, false, "Checked false state correctly cloned" ); + + elem = jQuery.parseHTML("<input type='checkbox'/>")[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("<div foo='bar'></div>").closest("[foo]").length, 1, "Disconnected nodes with attribute selector" ); equal( jQuery("<div>text</div>").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" ); |