#153 closed defect (wontfix)
[patch] fix for dojo.style.getNumericStyle
Reported by: | Owned by: | sjmiles | |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | Core | Version: | 0.1 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
This patch simplifies dojo.style.getNumericStyle() and makes it more reliable.
Index: style.js =================================================================== --- style.js (revision 1784) +++ style.js (working copy) @@ -99,11 +99,8 @@ var s = dojo.style.getComputedStyle(element, cssSelector); if (s == ''){ return 0; } if (dojo.lang.isUndefined(s)){ return NaN }; - var match = s.match(/([d.]+)([a-z]*)/); - if (!match || !match[1]) - return NaN; - var n = Number(match[1]); - return (n == 0 || match[2]=='px' ? n : NaN); + var match = s.match(/(d+)(px){0,1}/); + return (!match || !match[1]) ? NaN : Number(match[1]); } dojo.style.getMarginWidth = function(node){
Attachments (2)
Change History (8)
Changed 15 years ago by
Attachment: | dojo.style.patch added |
---|
Changed 15 years ago by
Attachment: | getNumericStyle.diff added |
---|
comment:1 Changed 15 years ago by
Owner: | changed from anonymous to paul |
---|
The patch I submitted would work slightly better, but I'm hesitent of applying it until the folks who use this function can test it out.
comment:2 Changed 15 years ago by
Owner: | changed from paul to [email protected]… |
---|
I assume you meant to reassign to me :-)
This is patch is based on sjmiles' work, it'd probably be better for him to review.
comment:3 Changed 15 years ago by
There are a few problems with the simplification:
- The original code is meant to extract the 'units' designation becuase in future we may support units other than just 'px'.
- Non-zero values in non-supported units must return NaN
- Numeric styles can contain decimals (not just integers), so we must allow '.'
comment:4 Changed 15 years ago by
Milestone: | → 0.4 |
---|---|
Owner: | changed from [email protected]… to sjmiles |
Can we close this?
comment:5 Changed 15 years ago by
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Closing this ticket. Please reopen if I missed some important detail.
Note: See
TracTickets for help on using
tickets.
slightly modified patch