diff options
author | Timmy Willison <timmywillisn@gmail.com> | 2015-05-05 08:33:50 -0700 |
---|---|---|
committer | Timmy Willison <timmywillisn@gmail.com> | 2015-05-05 08:53:17 -0700 |
commit | 0d11c1182f2012cd6eb06ce1e3fa5a495af9bee3 (patch) | |
tree | 82a78d6aa75943efdca5301d078190eb2635f772 | |
parent | 6176567361e9d05d4f5eb7e98735a678f2cd7ea9 (diff) | |
download | jquery-0d11c1182f2012cd6eb06ce1e3fa5a495af9bee3.tar.gz jquery-0d11c1182f2012cd6eb06ce1e3fa5a495af9bee3.zip |
Offset: allow offset setter to throw for disconnected elements
Fixes gh-2114
-rw-r--r-- | src/offset.js | 2 | ||||
-rw-r--r-- | test/unit/core.js | 10 |
2 files changed, 2 insertions, 10 deletions
diff --git a/src/offset.js b/src/offset.js index adcc8d64c..95658ca69 100644 --- a/src/offset.js +++ b/src/offset.js @@ -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" ) && diff --git a/test/unit/core.js b/test/unit/core.js index b355611d4..0a018dea4 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -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"); |