Skip to content

Commit ee69e9c

Browse files
committed
Revert "Offset: allow offset setter to throw for disconnected elements"
This reverts commit 0d11c11.
1 parent d8037c6 commit ee69e9c

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/offset.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jQuery.offset = {
3939
elem.style.position = "relative";
4040
}
4141

42-
curOffset = curElem.offset();
42+
curOffset = curElem.offset() || { top: 0, left: 0 };
4343
curCSSTop = jQuery.css( elem, "top" );
4444
curCSSLeft = jQuery.css( elem, "left" );
4545
calculatePosition = ( position === "absolute" || position === "fixed" ) &&

test/unit/core.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ test("jQuery()", function() {
3636
expected++;
3737
attrObj["width"] = 10;
3838
}
39+
if ( jQuery.fn.offset ) {
40+
expected++;
41+
attrObj["offset"] = { "top": 1, "left": 1 };
42+
}
3943
if ( jQuery.fn.css ) {
4044
expected += 2;
4145
attrObj["css"] = { "paddingLeft": 1, "paddingRight": 1 };
@@ -101,12 +105,16 @@ test("jQuery()", function() {
101105
elem = jQuery("\n\n<em>world</em>")[0];
102106
equal( elem.nodeName.toLowerCase(), "em", "leading newlines" );
103107

104-
elem = jQuery( "<div/>", attrObj );
108+
elem = jQuery("<div/>", attrObj );
105109

106110
if ( jQuery.fn.width ) {
107111
equal( elem[0].style.width, "10px", "jQuery() quick setter width");
108112
}
109113

114+
if ( jQuery.fn.offset ) {
115+
equal( elem[0].style.top, "1px", "jQuery() quick setter offset");
116+
}
117+
110118
if ( jQuery.fn.css ) {
111119
equal( elem[0].style.paddingLeft, "1px", "jQuery quick setter css");
112120
equal( elem[0].style.paddingRight, "1px", "jQuery quick setter css");

0 commit comments

Comments
 (0)