Skip to content

Fixed #9533 - Position: positioning within document raises error #1072

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion tests/unit/position/position_core.js
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,14 @@ test( "collision: flip, with margin", function() {
});

test( "within", function() {
expect( 6 );
expect( 7 );

collisionTest({
within : document
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No space before the colon, same thing for the next two.

}, {
top : 10,
left : 10
}, "within document (bug #9533)");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we have a few ticket references here and there, we should avoid them. The test speaks for itself. Can you remove the reference?


collisionTest({
within: "#within",
Expand Down
8 changes: 5 additions & 3 deletions ui/jquery.ui.position.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ $.position = {
return (cachedScrollbarWidth = w1 - w2);
},
getScrollInfo: function( within ) {
var overflowX = within.isWindow ? "" : within.element.css( "overflow-x" ),
overflowY = within.isWindow ? "" : within.element.css( "overflow-y" ),
var overflowX = within.isWindow || within.isDoc ? "" : within.element.css( "overflow-x" ),
overflowY = within.isWindow || within.isDoc ? "" : within.element.css( "overflow-y" ),
hasOverflowX = overflowX === "scroll" ||
( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
hasOverflowY = overflowY === "scroll" ||
Expand All @@ -101,10 +101,12 @@ $.position = {
},
getWithinInfo: function( element ) {
var withinElement = $( element || window ),
isWindow = $.isWindow( withinElement[0] );
isWindow = $.isWindow( withinElement[0] ),
isDoc = (!!withinElement[0] && withinElement[0].nodeType === 9);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a reference for this check?

return {
element: withinElement,
isWindow: isWindow,
isDoc: isDoc,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about isDocument? Would be more consistent with isWindow.

offset: withinElement.offset() || { left: 0, top: 0 },
scrollLeft: withinElement.scrollLeft(),
scrollTop: withinElement.scrollTop(),
Expand Down