Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit dc49f62

Browse files
committedMay 5, 2015
Offset: allow offset setter to throw for disconnected elements
Fixes gh-2114
1 parent a2386a8 commit dc49f62

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed
 

‎src/offset.js

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

‎test/unit/core.js

+1-9
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ 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-
}
4339
if ( jQuery.fn.css ) {
4440
expected += 2;
4541
attrObj["css"] = { "paddingLeft": 1, "paddingRight": 1 };
@@ -105,16 +101,12 @@ test("jQuery()", function() {
105101
elem = jQuery("\n\n<em>world</em>")[0];
106102
equal( elem.nodeName.toLowerCase(), "em", "leading newlines" );
107103

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

110106
if ( jQuery.fn.width ) {
111107
equal( elem[0].style.width, "10px", "jQuery() quick setter width");
112108
}
113109

114-
if ( jQuery.fn.offset ) {
115-
equal( elem[0].style.top, "1px", "jQuery() quick setter offset");
116-
}
117-
118110
if ( jQuery.fn.css ) {
119111
equal( elem[0].style.paddingLeft, "1px", "jQuery quick setter css");
120112
equal( elem[0].style.paddingRight, "1px", "jQuery quick setter css");

0 commit comments

Comments
 (0)
Failed to load comments.