Skip to main content

Bug Tracker

Side navigation

#2076 closed bug (fixed)

Opened December 18, 2007 01:50PM UTC

Closed December 18, 2007 05:26PM UTC

Last modified October 08, 2009 05:39AM UTC

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

Reported by: apaella@gmail.com Owned by:
Priority: major Milestone: 1.2.2
Component: core Version: 1.2.1
Keywords: Cc:
Blocked by: Blocking:
Description

call $.trim($('#id').val()) over a #id empty input throws an Error: (text || "").replace is not a function

$('#id').val() == []

and ([] || "") is not a string...

Attachments (1)
  • index.html (0.5 KB) - added by apaella@gmail.com December 18, 2007 01:50PM UTC.

    a live example

Change History (2)

Changed December 18, 2007 05:26PM UTC by davidserduke comment:1

resolution: → fixed
status: newclosed

Fixed in [4220].

Actually $.trim hasn't changed since 1.2.1 (and probably earlier). This problem was with val() and your test case. The test case doesn't wait till the document is ready so $("#foo").length == 0 as you noted. If you put the code inside

$(document).ready(function(){
    /* code here */
});

it will work fine.

But as it turned out this was a good test since val was incorrectly returning an empty array instead of undefined as it used to. One other thing, just for completeness, is your example has an input with type="input" but to my knowledge there is no such input type. Firefox converts that to type="text". I'm not sure what other browsers would do.

Changed December 20, 2007 11:03PM UTC by apaella@gmai comment:2

ops, sorry fom my double mistake :D

thanks for the patch.

great job!