Ticket #5803 (assigned defect)
dojo.getComputedStyle does not honor dojo.doc
| Reported by: | guest | Owned by: | sjmiles |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.2 |
| Component: | HTML | Version: | 1.0 |
| Severity: | normal | Keywords: | getComputedStyle dojo.doc dojo.withGlobal |
| Cc: | tdedischew@… |
Description
dojo.getComputedStyle doesn't recognize changes to dojo.doc / dojo.withGlobal because it caches the defaultView on load:
dojo/_base/html.js:262 var gcs, dv = document.defaultView;
If resolving dojo.doc.defaultView was/is an expensive operation I'm not sure what a good fix would be.
Adding a doc argument to getComputedStyle (like dojo.byId) could work, but this might be confusing since the standard W3C getComputedStyle uses a second arg already (pseudo element).
My temporary workaround is to just back out the cached dv reference:
if (!dojo.isIE)
dojo.getComputedStyle = eval(String(
dojo.getComputedStyle.toSource ?
dojo.getComputedStyle.toSource() :
dojo.getComputedStyle.toString()
).replace(/ dv./g, ' dojo.doc.defaultView.'));
Note: I discovered this issue on FF 1.5 when trying to get the computed style.position value -- using the wrong document's defaultView did not pick up CSS rules applied using class= and always returned position as "static"