aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorRichard McDaniel <rm0026@uah.edu>2014-10-16 15:32:46 -0400
committerTimmy Willison <timmywillisn@gmail.com>2015-05-12 10:34:57 -0400
commit2d715940b9b6fdeed005cd006c8bf63951cf7fb2 (patch)
tree37bb8dc950bf7876fb22e52299667a05281c61d4 /test/unit
parentc252c5fac2a25869524c2eba2e93d4230e6af25c (diff)
downloadjquery-2d715940b9b6fdeed005cd006c8bf63951cf7fb2.tar.gz
jquery-2d715940b9b6fdeed005cd006c8bf63951cf7fb2.zip
Offset: account for scroll when calculating position
Fixes gh-1708 Close gh-1714
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/offset.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/test/unit/offset.js b/test/unit/offset.js
index 1a467ecff..7b2ecc905 100644
--- a/test/unit/offset.js
+++ b/test/unit/offset.js
@@ -407,7 +407,7 @@ testIframe("offset/table", "table", function( $ ) {
});
testIframe("offset/scroll", "scroll", function( $, win ) {
- expect(24);
+ expect(28);
equal( $("#scroll-1").offset().top, 7, "jQuery('#scroll-1').offset().top" );
equal( $("#scroll-1").offset().left, 7, "jQuery('#scroll-1').offset().left" );
@@ -457,6 +457,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( $ ) {