Skip to content

Commit

Permalink
Revert "Offset: allow offset setter to throw for disconnected elements"
Browse files Browse the repository at this point in the history
This reverts commit 0d11c11.
  • Loading branch information
timmywil committed Jun 16, 2015
1 parent e831856 commit 578dcee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/offset.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jQuery.offset = {
elem.style.position = "relative";
}

curOffset = curElem.offset();
curOffset = curElem.offset() || { top: 0, left: 0 };
curCSSTop = jQuery.css( elem, "top" );
curCSSLeft = jQuery.css( elem, "left" );
calculatePosition = ( position === "absolute" || position === "fixed" ) &&
Expand Down
10 changes: 9 additions & 1 deletion test/unit/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ 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 };
Expand Down Expand Up @@ -101,12 +105,16 @@ 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");
Expand Down

0 comments on commit 578dcee

Please sign in to comment.