diff options
author | Richard Gibson <richard.gibson@gmail.com> | 2011-12-06 15:25:38 -0500 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2011-12-06 15:25:38 -0500 |
commit | 6c2a501de40a5f6b3ad382e2d309e5a10fce04d0 (patch) | |
tree | c72333c9a1d5d29acd4e3224ddf6d4e4e00db5fe /test/unit/offset.js | |
parent | d511613d748a92af04a3f07943f34f9baadc4153 (diff) | |
download | jquery-6c2a501de40a5f6b3ad382e2d309e5a10fce04d0.tar.gz jquery-6c2a501de40a5f6b3ad382e2d309e5a10fce04d0.zip |
Fix #5571. Setters should treat `undefined` as a no-op and be chainable.
Diffstat (limited to 'test/unit/offset.js')
-rw-r--r-- | test/unit/offset.js | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/test/unit/offset.js b/test/unit/offset.js index a37130653..466e65006 100644 --- a/test/unit/offset.js +++ b/test/unit/offset.js @@ -342,7 +342,7 @@ testoffset("table", function( jQuery ) { }); testoffset("scroll", function( jQuery, win ) { - expect(22); + expect(24); var ie = jQuery.browser.msie && parseInt( jQuery.browser.version, 10 ) < 8; @@ -362,8 +362,9 @@ testoffset("scroll", function( jQuery, win ) { equal( jQuery("#scroll-1-1").scrollTop(), 0, "jQuery('#scroll-1-1').scrollTop()" ); equal( jQuery("#scroll-1-1").scrollLeft(), 0, "jQuery('#scroll-1-1').scrollLeft()" ); - // equal( jQuery("body").scrollTop(), 0, "jQuery("body").scrollTop()" ); - // equal( jQuery("body").scrollLeft(), 0, "jQuery("body").scrollTop()" ); + // scroll method chaining + equal( jQuery("#scroll-1").scrollTop(undefined).scrollTop(), 5, ".scrollTop(undefined) is chainable (#5571)" ); + equal( jQuery("#scroll-1").scrollLeft(undefined).scrollLeft(), 5, ".scrollLeft(undefined) is chainable (#5571)" ); win.name = "test"; @@ -405,11 +406,12 @@ testoffset("body", function( jQuery ) { equal( jQuery("body").offset().left, 1, "jQuery('#body').offset().left" ); }); -test("Chaining offset(coords) returns jQuery object", function() { - expect(2); +test("chaining", function() { + expect(3); var coords = { top: 1, left: 1 }; equal( jQuery("#absolute-1").offset(coords).selector, "#absolute-1", "offset(coords) returns jQuery object" ); equal( jQuery("#non-existent").offset(coords).selector, "#non-existent", "offset(coords) with empty jQuery set returns jQuery object" ); + equal( jQuery("#absolute-1").offset(undefined).selector, "#absolute-1", "offset(undefined) returns jQuery object (#5571)" ); }); test("offsetParent", function(){ |