From 0654711e0d929187249ca9507ae5881c72947843 Mon Sep 17 00:00:00 2001 From: Richard McDaniel Date: Thu, 16 Oct 2014 15:32:46 -0400 Subject: Offset: account for scroll when calculating position Fixes gh-1708 Close gh-1714 --- test/unit/offset.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'test/unit') diff --git a/test/unit/offset.js b/test/unit/offset.js index 3977e3933..b6ec93de6 100644 --- a/test/unit/offset.js +++ b/test/unit/offset.js @@ -412,7 +412,7 @@ testIframe("offset/table", "table", function( $ ) { }); testIframe("offset/scroll", "scroll", function( $, win ) { - expect(24); + expect(28); // If we're going to bastardize the tests, let's just DO it var ie = /msie 8/i.test( navigator.userAgent ); @@ -473,6 +473,17 @@ testIframe("offset/scroll", "scroll", function( $, win ) { notEqual( $().scrollLeft(null), null, "jQuery().scrollLeft(null) testing setter on empty jquery object" ); strictEqual( $().scrollTop(), null, "jQuery().scrollTop(100) testing setter on empty jquery object" ); strictEqual( $().scrollLeft(), null, "jQuery().scrollLeft(100) testing setter on empty jquery object" ); + + // Tests position after parent scrolling (#15239) + $("#scroll-1").scrollTop(0); + $("#scroll-1").scrollLeft(0); + equal( $("#scroll-1-1").position().top, 6, "jQuery('#scroll-1-1').position().top unaffected by parent scrolling" ); + equal( $("#scroll-1-1").position().left, 6, "jQuery('#scroll-1-1').position().left unaffected by parent scrolling" ); + + $("#scroll-1").scrollTop(5); + $("#scroll-1").scrollLeft(5); + equal( $("#scroll-1-1").position().top, 6, "jQuery('#scroll-1-1').position().top unaffected by parent scrolling" ); + equal( $("#scroll-1-1").position().left, 6, "jQuery('#scroll-1-1').position().left unaffected by parent scrolling" ); }); testIframe("offset/body", "body", function( $ ) { -- cgit v1.2.3