aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorArthur Stolyar <nekr.fabula@gmail.com>2015-05-05 08:16:29 -0700
committerTimmy Willison <timmywillisn@gmail.com>2015-05-05 08:16:29 -0700
commit1617479fcf7cbdaf33dc9334ed10a0f30bf14687 (patch)
treee605b68a8f6b68c8b62e4b7751eedf89362f8f1c /test
parentadd85afed5944ec10d68ca10e91421e031fe0a5d (diff)
downloadjquery-1617479fcf7cbdaf33dc9334ed10a0f30bf14687.tar.gz
jquery-1617479fcf7cbdaf33dc9334ed10a0f30bf14687.zip
Offset: Fix .offset() to correctly work with ShadowDOM
Fixes gh-1784 Close gh-2043
Diffstat (limited to 'test')
-rw-r--r--test/unit/offset.js28
1 files changed, 23 insertions, 5 deletions
diff --git a/test/unit/offset.js b/test/unit/offset.js
index 785b23961..057aa6df7 100644
--- a/test/unit/offset.js
+++ b/test/unit/offset.js
@@ -56,13 +56,31 @@ test("object without getBoundingClientRect", function() {
equal( result.left, 0, "Check left" );
});
-test("disconnected node", function() {
- expect(2);
+test("disconnected element", function() {
+ expect(1);
- var result = jQuery( document.createElement("div") ).offset();
+ var result;
- equal( result.top, 0, "Check top" );
- equal( result.left, 0, "Check left" );
+ try {
+ result = jQuery( document.createElement("div") ).offset();
+ } catch ( e ) {}
+
+ ok( !result, "no position for disconnected element" );
+});
+
+test("hidden (display: none) element", function() {
+ expect(1);
+
+ var result,
+ node = jQuery("<div style='display: none' />").appendTo("#qunit-fixture");
+
+ try {
+ result = node.offset();
+ } catch ( e ) {}
+
+ node.remove();
+
+ ok( !result, "no position for hidden (display: none) element" );
});
testIframe("offset/absolute", "absolute", function($, iframe) {