jQuery.fn.extend( {
offset: function( options ) {
-
- // Preserve chaining for setter
if ( arguments.length ) {
return options === undefined ?
this :
} );
}
- var docElem, win, rect, doc,
- elem = this[ 0 ];
+ var docElem, win, rect,
+ elem = this[ 0 ],
+ doc = elem && elem.ownerDocument;
- if ( !elem ) {
+ if ( !doc ) {
return;
}
the iframe window and the "jQuery" symbol is used to access any static methods.
*/
-QUnit.test( "empty set", function( assert ) {
- assert.expect( 2 );
- assert.strictEqual( jQuery().offset(), undefined, "offset() returns undefined for empty set (#11962)" );
- assert.strictEqual( jQuery().position(), undefined, "position() returns undefined for empty set (#11962)" );
-} );
+test("empty set", function() {
+ expect(2);
+ strictEqual( jQuery().offset(), undefined, "offset() returns undefined for empty set (#11962)" );
+ 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" );
+});
QUnit.test( "disconnected element", function( assert ) {
assert.expect( 2 );