]> source.dussan.org Git - jquery.git/commitdiff
Offset: allow offset setter to throw for disconnected elements
authorTimmy Willison <timmywillisn@gmail.com>
Tue, 5 May 2015 15:33:50 +0000 (08:33 -0700)
committerTimmy Willison <timmywillisn@gmail.com>
Tue, 5 May 2015 16:00:41 +0000 (09:00 -0700)
Fixes gh-2114

src/offset.js
test/unit/core.js

index e4a706ee0969a33c67d7901243735b54c2b46bfa..8e355123cb9bc00b27ff82561484a64bbb051f03 100644 (file)
@@ -39,7 +39,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" ) &&
index f1a302784a734372e866313427de781a3841889b..39e61fcb6194e78264e69886072538c77bf82106 100644 (file)
@@ -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");