Ticket #10961 (closed bug: fixed)
Error in XRegExp using jQuery 1.7.1 in IE6-9
| Reported by: | rworth | Owned by: | dmethvin |
|---|---|---|---|
| Priority: | low | Milestone: | 1.7.2 |
| Component: | event | Version: | 1.7.1 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
When upgrading to the latest jQuery, 1.7.1, I found a regression when using the popular XRegExp library (a dependency of the popular SyntaxHighlighter). The error occurs in all versions of IE. Wasn't able to get it running on jsFiddle, but here's the minimal test case:
<script src=http://code.jquery.com/jquery-1.7.1.js></script>
<script src=http://xregexp.com/xregexp.js></script>
<script>
jQuery(window).bind("click", function() {});
</script>
And the error:
Unable to get value of the property 'slice': object is null or undefined (line 281) (xregexp.js)
Even though the error is showing up on a line number in xregexp, that library is stable since March 2010, and works with all previous stable versions of jQuery (1.0.4, 1.1.4, 1.2.6, 1.3.2, 1.4.4, 1.5.2, 1.6.4, 1.7.0), so this is a regression in jQuery 1.7.1
Change History
comment:2 Changed 18 months ago by sindresorhus
XRegExp is naughty and overrides the RegExp.prototype.exec which jQuery uses 26 times.
I don't think jQuery should fix incompatibilities with libraries that modifies the built-in prototypes.
-1.
comment:3 Changed 18 months ago by dmethvin
- Owner set to dmethvin
- Priority changed from undecided to low
- Status changed from new to assigned
- Component changed from unfiled to event
- Milestone changed from None to 1.7.2
I see what's happening though, their shimmed .exec() doesn't like being passed undefined but the native ones are fine with it. It's an easy fix so we might as well.
comment:4 Changed 18 months ago by Dave Methvin
- Status changed from assigned to closed
- Resolution set to fixed
Fix #10961. XRegExp's shimmed .exec() can't handle undefined.
There's no reason to call quickParse if selector is falsy, so it's a minor performance optimization anyway. No change in behavior at all on our side, so no test case needed.
Changeset: 5798eab1240734e5d04a85acd628d007f4c93765
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Using git bisect, tracked this down to https://github.com/jquery/jquery/commit/a7e911b7fe84a35234d4be18102e168c6644e40d