OpenLayers OpenLayers

Ticket #1441 (closed feature: fixed)

Opened 6 months ago

Last modified 1 day ago

Add OpenLayers.String.isNumeric method

Reported by: tschaub Assigned to: tschaub
Priority: minor Milestone: 2.7 Release
Component: BaseTypes Version: 2.5
Keywords: Cc:
State: Complete

Description (Last modified by euzuro)

There are a number of isNaN(value) tests lurking around. If we want to explicitly check if a string represents a number, I'd like to add a OpenLayers.String.isNumeric function.

Comparisons (assuming you think !isNaN is a good test to see if a string is numeric):

Areas of agreement

!isNaN("foo") // false
OpenLayers.String.isNumeric("foo") // false

!isNaN("1") // true
OpenLayers.String.isNumeric("1") // true

!isNaN(undefined) // false
OpenLayers.String.isNumeric(undefined) // false

Areas of disagreement

!isNaN("") // true
OpenLayers.String.isNumeric("") // false

!isNaN(null) // true
OpenLayers.String.isNumeric(null) // false

!isNaN(true) // true
OpenLayers.String.isNumeric(true) // false

!isNaN(false) // true
OpenLayers.String.isNumeric(false) // false

Attachments

numeric.patch (2.6 kB) - added by tschaub on 03/16/08 17:25:34.
test if a string represents a number

Change History

03/16/08 17:25:34 changed by tschaub

  • attachment numeric.patch added.

test if a string represents a number

03/16/08 17:26:52 changed by tschaub

  • state set to Review.

03/17/08 11:27:18 changed by euzuro

  • description changed.
  • summary changed from Add OpenLayers.String.isNumberic method to Add OpenLayers.String.isNumeric method.

03/17/08 11:30:20 changed by tschaub

I sort of liked isNumberic.

03/17/08 11:36:46 changed by euzuro

patch looks good. i cant imagine a use for this, but im sure you can.

ND comment is missing the "Parameters: " section

if you can verify that tests pass in ie and ff, id say good to commit (for 2.7)

06/09/08 15:11:03 changed by tschaub

(In [7334]) The text format conditionally sets values for feature.style.graphicXOffset and graphicYOffset. If these are not defined in parsing, we confirm that using the non-identity operator with undefined. Later, it might make sense to confirm these values are actually numeric (see #1441). This keeps an icon.offset from inadvertently getting created with NaN values later on. r=elemoine (closes #1571)

06/19/08 18:17:35 changed by crschmidt

  • state changed from Review to Commit.

Thanks for the comprehensive testing. I'm convinced this will work fine in IE; please go ahead to commit.

06/25/08 16:37:29 changed by tschaub

  • status changed from new to closed.
  • state changed from Commit to Complete.
  • resolution set to fixed.

(In [7451]) Adding OL.String.isNumeric method to test for numeric strings. r=crschmidt (closes #1441)

09/05/08 02:19:31 changed by euzuro

  • component changed from general to BaseTypes.