Opened 16 years ago

Closed 15 years ago

Last modified 15 years ago

#153 closed defect (wontfix)

[patch] fix for

Reported by: [email protected] Owned by: sjmiles
Priority: high Milestone:
Component: Core Version: 0.1
Keywords: Cc:
Blocked By: Blocking:


This patch simplifies and makes it more reliable.

Index: style.js
--- style.js	(revision 1784)
+++ style.js	(working copy)
@@ -99,11 +99,8 @@
 	var s =, 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]);
 } = function(node){

Attachments (2) (610 bytes) - added by [email protected] 16 years ago.
getNumericStyle.diff (599 bytes) - added by david 16 years ago.
slightly modified patch

Download all attachments as: .zip

Change History (8)

Changed 16 years ago by [email protected]

Attachment: added

Changed 16 years ago by david

Attachment: getNumericStyle.diff added

slightly modified patch

comment:1 Changed 16 years ago by david

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 16 years ago by psowden

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 16 years ago by [email protected]

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 16 years ago by dylan

Milestone: 0.4
Owner: changed from [email protected] to sjmiles

Can we close this?

comment:5 Changed 15 years ago by sjmiles

Resolution: wontfix
Status: newclosed

Closing this ticket. Please reopen if I missed some important detail.

comment:6 Changed 15 years ago by (none)

Milestone: 0.4

Milestone 0.4 deleted

Note: See TracTickets for help on using tickets.