Ticket #10581 (closed bug: wontfix)
JQuery change String.prototype.split in IE < 9 (add trim)
| Reported by: | vohhov@… | Owned by: | vohhov@… |
|---|---|---|---|
| Priority: | low | Milestone: | None |
| Component: | core | Version: | 1.7b2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
In IE 6, 7, 8: (' a ').split(/\s+/).length == 1 but should be 3.
Change History
comment:2 follow-up: ↓ 3 Changed 19 months ago by rwaldron
- Priority changed from undecided to low
- Resolution set to wontfix
- Status changed from new to closed
- Component changed from unfiled to misc
jQuery does not modify native objects.
comment:3 in reply to: ↑ 2 Changed 19 months ago by anonymous
Replying to 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.
comment:4 Changed 19 months ago by rwaldron
- Priority changed from low to high
- Resolution wontfix deleted
- Status changed from closed to reopened
- Component changed from misc to core
Your subject...
JQUERY CHANGE STRING.PROTOTYPE.SPLIT
implies that jQuery has changed something.
comment:5 follow-up: ↓ 6 Changed 19 months ago by rwaldron
- Owner set to vohhov@…
- Priority changed from high to low
- Status changed from reopened to pending
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.
comment:6 in reply to: ↑ 5 Changed 19 months ago by anonymous
Replying to 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.
comment:7 follow-up: ↓ 8 Changed 19 months ago by rwaldron
- Status changed from pending to closed
- Resolution set to wontfix
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.
comment:8 in reply to: ↑ 7 Changed 19 months ago by anonymous
Replying to 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.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

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