Ticket #1958 (closed defect: wontfix)
dojo.html.insertCssText causes "Invalid procedure call or argument" in IE when styleSheet.disabled is true
| Reported by: | aaronmevans@… | Owned by: | alex |
|---|---|---|---|
| Priority: | normal | Milestone: | 0.9 |
| Component: | General | Version: | 0.4.1rc1 |
| Severity: | normal | Keywords: | stylesheet, disabled, IE, error |
| Cc: |
Description
In dojo.html.style.js, in the function dojo.html.insertCssText, there is some special handling for IE for setting the css text on the style dom node:
if(style.styleSheet){// IE
style.styleSheet.cssText = cssStr;
}
However, if style.styleSheet.disabled is true, then you get the error "Invalid procedure call or argument" (both IE 6 and IE 7).
Why style.styleSheet.disabled is sometimes true I have no idea, it just is in one of my particular test cases. Unfortunately, I cannot reduce the test case to something small enough to post.
However, I have attached a workaround that solves the issue. I just do this instead:
if(style.styleSheet){// IE
if(!style.styleSheet.disabled){
style.styleSheet.cssText = cssStr;
}
}
Now I realize that without the reproducible test case, you might be a little hesitant to apply this patch (which I will attach shortly).
However, it stands to reason that even if you can't produce a test case where the style sheet ends up with disabled=true, if we just suppose that if it were somehow disabled, that attempting to modify it would throw some kind of error (and it does, trust me).
So why not just add the extra handling anyway as a precaution? It's not that many extra characters. :)
-aaron