Skip to main content

Bug Tracker

Side navigation

#10581 closed bug (wontfix)

Opened October 26, 2011 12:44PM UTC

Closed October 26, 2011 07:29PM UTC

Last modified October 26, 2011 07:55PM UTC

JQuery change String.prototype.split in IE < 9 (add trim)

Reported by: vohhov@gmail.com Owned by: vohhov@gmail.com
Priority: low Milestone: None
Component: core Version: 1.7b2
Keywords: Cc:
Blocked by: Blocking:
Description

In IE 6, 7, 8:

(' a ').split(/\\s+/).length == 1

but should be 3.

Attachments (0)
Change History (8)

Changed October 26, 2011 01:51PM UTC by vohhov@gmail.com comment:1

Not only for spaces: 'xAx'.split(/x/).length == 1

but should be 3.

Changed October 26, 2011 01:55PM UTC by rwaldron comment:2

component: unfiledmisc
priority: undecidedlow
resolution: → wontfix
status: newclosed

jQuery does not modify native objects.

Changed October 26, 2011 07:05PM UTC by anonymous comment:3

Replying to [comment:2 rwaldron]:

jQuery does not modify native objects.

Yes, jQuery should not modify the native objects, and in its code, it does not, but in fact changes occur, it is easily and consistently reproduced (just try it).

I don't know how it happens, but it is a serious bug that prevents work. Of course, part of the blame lies with IE.

Changed October 26, 2011 07:08PM UTC by rwaldron comment:4

component: misccore
priority: lowhigh
resolution: wontfix
status: closedreopened

Your subject...

JQUERY CHANGE STRING.PROTOTYPE.SPLIT

implies that jQuery has changed something.

Changed October 26, 2011 07:12PM UTC by rwaldron comment:5

owner: → vohhov@gmail.com
priority: highlow
status: reopenedpending

I'm still not sure where the jQuery bug is...? I just tested this: http://jsfiddle.net/rwaldron/4k9aw/show/light/ in IE98 and the result for jQuery.trim() was as expected.

Changed October 26, 2011 07:27PM UTC by anonymous comment:6

Replying to [comment:5 rwaldron]:

I'm still not sure where the jQuery bug is...? I just tested this: http://jsfiddle.net/rwaldron/4k9aw/show/light/ in IE98 and the result for jQuery.trim() was as expected.

Try this in IE8, in any site with jQuery (in IE9 all correct):

'xAx'.split(/x/).length

You should now have 3, but it turns 1, as if somewhere inside the trim is applied for 'xAx' before split.

Maybe the reason is that in the IE < 9 function trim not native.

Changed October 26, 2011 07:29PM UTC by rwaldron comment:7

resolution: → wontfix
status: pendingclosed

So, where is the bug in jQuery? String.prototype.split is not jQuery's domain...

I recommend using Underscore: http://documentcloud.github.com/underscore/ for compatible utility methods.

Changed October 26, 2011 07:55PM UTC by anonymous comment:8

Replying to [comment:7 rwaldron]:

So, where is the bug in jQuery? String.prototype.split is not jQuery's domain... I recommend using Underscore: http://documentcloud.github.com/underscore/ for compatible utility methods.

You're right, and I was wrong: it seems to be a bug of IE and it does not depend on jQuery. Sorry for your trouble.