Bug Tracker

Modify

Ticket #4452 (closed bug: fixed)

Opened 4 years ago

Last modified 3 years ago

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:

Error: (text
"").replace is not a function

Source: jquery-1.3.2.js, Line: 1067

IMHO this should return "1"

Change History

comment:1 Changed 4 years ago by dmethvin

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.

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)

comment:3 Changed 4 years ago by flesler

  • Cc buchi added
  • Owner set to flesler

comment:4 Changed 3 years ago by john

  • Status changed from new to closed
  • Version changed from 1.3.2 to 1.4.2
  • Resolution set to fixed
  • Milestone changed from 1.4 to 1.4.3

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.