Modify ↓
Ticket #4452 (closed bug: fixed)
Error when calling jQuery.trim
| Reported by: | buchi | Owned by: | flesler |
|---|---|---|---|
| Priority: | major | Milestone: | 1.4.3 |
| Component: | core | Version: | 1.4.2 |
| Keywords: | trim, integer | Cc: | buchi |
| Blocking: | Blocked by: |
Description
Calling: jQuery.trim(1)
results in:
| "").replace is not a function |
Source: jquery-1.3.2.js, Line: 1067
IMHO this should return "1"
Change History
comment:2 Changed 4 years ago by buchi
Maybe you know it better than I and you're right when passing other objects to jQuery.trim, but in case of an integer it could return the string version of this integer. So the trim-regex won't be needed. I wanted to discuss this behaviour because I got the mentioned error and at first I had no idea what was wrong. Other functions also handle integers like strings, e.g. alert("123") does the same as alert(123)
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

What should it return on an object, function, regexp, or date object? In some cases it's just best to give the user an error asap.