Permalink
Browse files

Offset: allow offset setter to throw for disconnected elements

Fixes gh-2114
  • Loading branch information...
timmywil committed May 5, 2015
1 parent 6176567 commit 0d11c1182f2012cd6eb06ce1e3fa5a495af9bee3
Showing with 2 additions and 10 deletions.
  1. +1 −1 src/offset.js
  2. +1 −9 test/unit/core.js
View
@@ -32,7 +32,7 @@ jQuery.offset = {
elem.style.position = "relative";
}
- curOffset = curElem.offset() || { top: 0, left: 0 };
+ curOffset = curElem.offset();
curCSSTop = jQuery.css( elem, "top" );
curCSSLeft = jQuery.css( elem, "left" );
calculatePosition = ( position === "absolute" || position === "fixed" ) &&
View
@@ -36,10 +36,6 @@ test("jQuery()", function() {
expected++;
attrObj["width"] = 10;
}
- if ( jQuery.fn.offset ) {
- expected++;
- attrObj["offset"] = { "top": 1, "left": 1 };
- }
if ( jQuery.fn.css ) {
expected += 2;
attrObj["css"] = { "paddingLeft": 1, "paddingRight": 1 };
@@ -105,16 +101,12 @@ test("jQuery()", function() {
elem = jQuery("\n\n<em>world</em>")[0];
equal( elem.nodeName.toLowerCase(), "em", "leading newlines" );
- elem = jQuery("<div/>", attrObj );
+ elem = jQuery( "<div/>", attrObj );
if ( jQuery.fn.width ) {
equal( elem[0].style.width, "10px", "jQuery() quick setter width");
}
- if ( jQuery.fn.offset ) {
- equal( elem[0].style.top, "1px", "jQuery() quick setter offset");
- }
-
if ( jQuery.fn.css ) {
equal( elem[0].style.paddingLeft, "1px", "jQuery quick setter css");
equal( elem[0].style.paddingRight, "1px", "jQuery quick setter css");

0 comments on commit 0d11c11

Please sign in to comment.