Opened 13 years ago

Closed 12 years ago

#2151 closed defect (fixed)

getComputedStyle doesn't use defaultView from Node

Reported by: nrlz@… Owned by: liucougar
Priority: high Milestone: 0.9
Component: Style Version: 0.4.1
Keywords: Cc:
Blocked By: Blocking:

Description

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 13 years ago.
testcase (Firefox only)

Download all attachments as: .zip

Change History (6)

Changed 13 years ago by nrlz

Attachment: css.htm added

testcase (Firefox only)

comment:1 Changed 12 years ago by dylan

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

comment:2 Changed 12 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:

http://dojotoolkit.org/pipermail/dojo-interest/2006-December/022393.html

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 12 years ago by gregory.murray@…

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 12 years ago by liucougar

Owner: changed from dylan to liucougar
Status: assignednew

comment:5 Changed 12 years ago by liucougar

Resolution: fixed
Status: newclosed

(In [7877]) fixes #2151

Note: See TracTickets for help on using tickets.