Opened 13 years ago
Closed 13 years ago
#6659 closed defect (duplicate)
dojo.getComputedStyle functions poorly in IE6 and FF when given the document object
Reported by: | Joseph Scheuhammer | Owned by: | sjmiles |
---|---|---|---|
Priority: | high | Milestone: | 1.2 |
Component: | HTML | Version: | 1.1.0 |
Keywords: | Cc: | Douglas Hays, davidb, Becky Gibson | |
Blocked By: | Blocking: |
Description
The document object is sometimes passed to dojo.getComputedStyle(). That causes a null value to be returned, or an exception to be thrown, depending on the browser.
getComputedStyle() is actually defined as gcs() in .../dojo/_base/html.js, and is defined differently for different browsers.
For IE6, the return value is node.currentStyle
, but that is null
when node
is the document. I suggest returning an empty object instead.
For FF2 and FF3, the style is retrieved via document.defaultView.getComputedStyle(node)
. When node
is the document, an exception is thrown: "[Exception:..."Could not convert JavaScript argument" ...]
This is because defaultView.getComputedStyle()
takes an Element
as its argument, and document is not an element.
A possible solution is to catch the exception and return an empty object.
The suggested changes are given in the attached patch file.
Another possibility is to restrict the argument type to Element
when invoking gcs(), but I'm unsure how much other code is affected by that change.