Opened 16 years ago

Closed 15 years ago

#2151 closed defect (fixed)

getComputedStyle doesn't use defaultView from Node

Reported by: [email protected] Owned by: liucougar
Priority: high Milestone: 0.9
Component: Style Version: 0.4.1
Keywords: Cc:
Blocked By: Blocking:


dojo.html.getComputedStyle should use the defaultView of the node's owning document instead of the defaultView which dojo is loaded from. This allows getComputedStyle to work on nodes from other documents (e.g., inside iframes).

i.e., dojo uses: document.defaultView.getComputedStyle(node, "").getPropertyValue(cssSelector);

but it should use: node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(cssSelector);

Attachments (1)

css.htm (965 bytes) - added by nrlz 16 years ago.
testcase (Firefox only)

Download all attachments as: .zip

Change History (6)

Changed 16 years ago by nrlz

Attachment: css.htm added

testcase (Firefox only)

comment:1 Changed 15 years ago by dylan

Milestone: 0.9
Owner: changed from anonymous to dylan
Status: newassigned

comment:2 Changed 15 years ago by stenduncan

I posted a question to the dojo-interest list that seems related to this (thanks to Robert Coup for pointing me here). My original post is at:

Basically my problem involves nested iframes and the accessibility function "testAccessible" (a11y.js). There is a call to getComputedStyle(div,"") which actually returns null and therefore causes the script to then fail on the next line.

Hopefully the fix made for this ticket will also fix that problem.

comment:3 Changed 15 years ago by [email protected]

I just ran into the same problem

A quick fix would be to change line 32 to the following:

if (cStyle) bkImg = cStyle.getPropertyValue("background-image");

Keep in mind this is a temporary solution.

comment:4 Changed 15 years ago by liucougar

Owner: changed from dylan to liucougar
Status: assignednew

comment:5 Changed 15 years ago by liucougar

Resolution: fixed
Status: newclosed

(In [7877]) fixes #2151

Note: See TracTickets for help on using tickets.