#893 closed defect (worksforme)
style.js fix to handle Safari returning empty string for values instead of 0px.
Reported by: | Owned by: | anonymous | |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | Style | Version: | 0.3 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
dojo.style.getUnitValue() was receiving null from dojo.style.getComputedStyle because the value was an empty string instead of 0px. This was because it was for a dom node that had display: none or maybe wasn't attached to the document at all. At any rate the fix was merely to check for null and return Nan rather than letting it throw an exception when it tried to access a property of the null value a few lines later. The NaN value seems to have repercussions elsewhere, but I'll submit a patch to the ones I've found in another bug.
This is a the svn commit message generated by our repository, but it is being committed against a clean dojo 0.3 kitchen sink distribution, so the line numbers are good.
Modified: adserver/trunk/js_dev/js/dojo/src/style.js =================================================================== --- adserver/trunk/js_dev/js/dojo/src/style.js 2006-06-03 01:43:34 UTC (rev 838) +++ adserver/trunk/js_dev/js/dojo/src/style.js 2006-06-03 01:52:28 UTC (rev 839) @@ -109,7 +109,7 @@
var result = { value: 0, units: 'px' }; var s = dojo.style.getComputedStyle(node, cssSelector);
if (s == (s == 'auto' && autoIsZero)){ return result; }
- if (dojo.lang.isUndefined(s)){
s==null){ |
result.value = NaN;
}else{
FIXME: is regex inefficient vs. parseInt or some manual test?
Attachments (1)
Change History (4)
Changed 15 years ago by
comment:1 Changed 15 years ago by
comment:2 Changed 15 years ago by
Component: | General → Style |
---|---|
Milestone: | → 0.4 |
Resolution: | → worksforme |
Status: | new → closed |
this has been pretty substantially rewritten since this patch, so closing as works for me.
I attached the text file instead of pasting it, after seeing how ugly it looked.