Skip to main content

Bug Tracker

Side navigation

#1661 closed bug (fixed)

Opened September 18, 2007 08:07PM UTC

Closed November 28, 2007 07:00PM UTC

curCSS does not validate returned value of getComputedStyle

Reported by: lmnt Owned by: davidserduke
Priority: major Milestone: 1.2.2
Component: core Version: 1.2.1
Keywords: Cc:
Blocked by: Blocking:
Description

in line 729 of jquery 1.2.1:

ret = prop == "display" && swap[stack.length-1] != null ?
    "none" :
    document.defaultView.getComputedStyle(elem,null).getPropertyValue(prop) || "";

this could probably be done more elegantly but for my purposes it's suited.

will fail if getComputedStyle() does not return as expected (such as when working with iframes). This is easily remedied by adding a simple check:

ret = prop == "display" && swap[stack.length-1] != null ?
    "none" :
    (document.defaultView.getComputedStyle(elem,null) ? 
        document.defaultView.getComputedStyle(elem,null).getPropertyValue(prop) || "" : "" 
    );
Attachments (0)
Change History (7)

Changed September 21, 2007 12:29PM UTC by danielnashnz comment:1

You got there before me!

Shouldn't the code be:

ret = (prop == "display" && swap[stack.length-1] != null) ? "none" : (document.defaultView.getComputedStyle(elem,null) != null) ? document.defaultView.getComputedStyle(elem,null).getPropertyValue(prop) : "";

??

Changed October 17, 2007 05:30PM UTC by mc_funkster comment:2

I vote for this bug to get fixed (soon) with danielnashnz' fix.

Imnt is missing a ')' after the check for a null computed style

Changed November 10, 2007 03:18AM UTC by geoffreyk comment:3

I just ran headlong into this bug as well with an iframe.

Seems that the fix is simple and localized.

Just trying to pump this bug up a bit. (I hate to run with a patched version of jquery)

Changed November 12, 2007 07:39PM UTC by davidserduke comment:4

This appears like it could be the same as #1779 which was fixed.

Changed November 12, 2007 07:49PM UTC by geoffreyk comment:5

I don't think so.

I just applied the changes from 1779, and that doesn't fix this problem.

this code does seem to fix the problem, though I don't know how this would affect #1779

				ret = (prop == "display" && swap[stack.length-1] != null) ? 
					"none" : 
					(document.defaultView.getComputedStyle(elem,null) != null) ? 
						document.defaultView.getComputedStyle(elem,null).getPropertyValue(prop) : "";

Changed November 18, 2007 02:32AM UTC by davidserduke comment:6

need: CommitTest Case
owner: → davidserduke
status: newassigned

Do you have a test case I could use that displays the problem?

Changed November 28, 2007 07:00PM UTC by davidserduke comment:7

resolution: → fixed
status: assignedclosed

If you applied the patch to 1.2.1 then it definitely won't work. Some other changes have been made to the function in SVN that are required.

I think this is fixed in SVN and am going to mark it as such. If you have a test case that doesn't work please attach it and reopen the bug.

So fixed in [3644].