Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix #12534. Don't die on browsers lacking getBoundingClientRect.

  • Loading branch information...
commit b0a352bfa76cbe1b65f8186d3cb90fe35a08866d 1 parent 74cdd78
Dave Methvin dmethvin authored
Showing with 11 additions and 2 deletions.
  1. +2 −2 src/offset.js
  2. +9 −0 test/unit/offset.js
4 src/offset.js
View
@@ -23,8 +23,8 @@ jQuery.fn.offset = function( options ) {
docElem = doc.documentElement;
- // Make sure we're not dealing with a disconnected DOM node
- if ( !jQuery.contains( docElem, elem ) ) {
+ // Make sure we have the API and we're it's not a disconnected DOM node
Dave Methvin Owner

GAAH!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ if ( typeof elem.getBoundingClientRect === "undefined" || !jQuery.contains( docElem, elem ) ) {
return { top: 0, left: 0 };
}
9 test/unit/offset.js
View
@@ -15,6 +15,15 @@ test("empty set", function() {
strictEqual( jQuery().position(), undefined, "position() returns undefined for empty set (#11962)" );
});
+test("object without getBoundingClientRect", function() {
+ expect(2);
+
+ // Simulates a browser without gBCR on elements, we just want to return 0,0
+ var result = jQuery({ ownerDocument: document }).offset();
+ equal( result.top, 0, "Check top" );
+ equal( result.left, 0, "Check left" );
+});
+
test("disconnected node", function() {
expect(2);
Dave Methvin

GAAH!

Please sign in to comment.
Something went wrong with that request. Please try again.