Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#9533 closed bug (fixed)

Position: positioning within document raises error

Reported by: meyertee Owned by: meyertee
Priority: minor Milestone: 1.10.4
Component: ui.position Version: 1.10.3
Keywords: Cc:
Blocked by: Blocking:

Description

jQuery raises an error when trying to position an element within the document:

$( "#elx" ).position({
	my: "left top",
	at: "right bottom",
	of: "#parent",
	within : document
});

The reason is that jquery-ui tries to access '$(document).css( "overflow-x" )' which causes an error in jQuery. Maybe that's a bug in jQuery itself, not sure if it's legal to access css of document. Either way I created a fix for it in jquery-ui. Pull request will follow shortly.

The underlying reason in jQuery is that it tries to map the style property in the 'css' function to a vendor prefixed property in this line, causing the error in the 'vendorPropName' function:

// Make sure that we're working with the right name
name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );

Because the vendor-prefixed names are cached, the error does not occur when the style-prop "overflow-x" is used on another element earlier, which makes the bug especially hard to catch!

Change History (8)

comment:1 Changed 5 years ago by meyertee

comment:2 Changed 5 years ago by tj.vantoll

Owner: set to meyertee
Status: newpending

Hi meyertee,

Thanks for taking the time to contribute to the jQuery UI project. I'm not seeing the error you're describing - document seems to work fine: http://jsfiddle.net/tj_vantoll/cwEpz/.

Could you please alter my test case to show the error you're seeing?

Thanks.

comment:3 Changed 5 years ago by meyertee

Status: pendingnew

Thanks for looking into it! The culprit is "within:document": http://jsfiddle.net/meyertee/cwEpz/5/

comment:4 Changed 5 years ago by meyertee

Sorry for the status-change to "new", but I can't deselect "leave as new" when submitting a comment...

comment:5 Changed 5 years ago by tj.vantoll

Status: newopen

Ah ok, this seems like a legit request to me as we accept document most other places.

comment:6 Changed 5 years ago by Thomas Meyer

Resolution: fixed
Status: openclosed

Position: Avoid reading overflow css on documents

Fixes #9533 Closes gh-1072

Changeset: 1bbbcc723c489d7ef7d72bb62564b8f07805c41c

comment:7 Changed 5 years ago by Thomas Meyer

Position: Avoid reading overflow css on documents

Fixes #9533 Closes gh-1072 (cherry picked from commit 1bbbcc723c489d7ef7d72bb62564b8f07805c41c)

Changeset: c8b264006d2fd8d9c27cfa8aef619428c563cb80

comment:8 Changed 5 years ago by Scott González

Milestone: none1.10.4
Note: See TracTickets for help on using tickets.