Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#893 closed defect (worksforme)

style.js fix to handle Safari returning empty string for values instead of 0px.

Reported by: sgendler@… 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)){
+ if (dojo.lang.isUndefined(s)
s==null){

result.value = NaN;

}else{

FIXME: is regex inefficient vs. parseInt or some manual test?

Attachments (1)

patch.txt (673 bytes) - added by anonymous 13 years ago.

Download all attachments as: .zip

Change History (4)

Changed 13 years ago by anonymous

Attachment: patch.txt added

comment:1 Changed 13 years ago by anonymous

I attached the text file instead of pasting it, after seeing how ugly it looked.

comment:2 Changed 13 years ago by dylan

Component: GeneralStyle
Milestone: 0.4
Resolution: worksforme
Status: newclosed

this has been pretty substantially rewritten since this patch, so closing as works for me.

comment:3 Changed 12 years ago by (none)

Milestone: 0.4

Milestone 0.4 deleted

Note: See TracTickets for help on using tickets.