diff options
author | Arthur Stolyar <nekr.fabula@gmail.com> | 2015-05-05 08:16:29 -0700 |
---|---|---|
committer | Timmy Willison <timmywillisn@gmail.com> | 2015-05-05 08:16:29 -0700 |
commit | 1617479fcf7cbdaf33dc9334ed10a0f30bf14687 (patch) | |
tree | e605b68a8f6b68c8b62e4b7751eedf89362f8f1c /test | |
parent | add85afed5944ec10d68ca10e91421e031fe0a5d (diff) | |
download | jquery-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.js | 28 |
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) { |