Skip to content

Commit f0189d6

Browse files
committed
Fixed the issue where weird characters were being used in ID selectors. Fixes jQuery bug jquery#3913.
1 parent 22c9c9b commit f0189d6

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

src/selector.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
(function(){
88

9-
var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[]+)+|[>+~])(\s*,\s*)?/g,
9+
var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,
1010
done = 0,
1111
toString = Object.prototype.toString;
1212

test/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ <h2 id="userAgent"></h2>
5050
<p id="sap">This link has <code><a href="#2" id="anchor2">class="blog"</a></code>: <a href="http://simon.incutio.com/" class="blog link" id="simon">Simon Willison's Weblog</a></p>
5151

5252
</div>
53+
<span id="name+value"></span>
5354
<p id="first">Try them out:</p>
5455
<ul id="firstUL"></ul>
5556
<ol id="empty"></ol>

test/unit/selector.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ test("broken", function() {
6969
});
7070

7171
test("id", function() {
72-
expect(27);
72+
expect(28);
7373
t( "ID Selector", "#body", ["body"] );
7474
t( "ID Selector w/ Element", "body#body", ["body"] );
7575
t( "ID Selector w/ Element", "ul#first", [] );
@@ -105,6 +105,8 @@ test("id", function() {
105105

106106
t( "Underscore ID", "#types_all", ["types_all"] );
107107
t( "Dash ID", "#fx-queue", ["fx-queue"] );
108+
109+
t( "ID with weird characters in it", "#name\\+value", ["name+value"] );
108110
});
109111

110112
test("class", function() {

0 commit comments

Comments
 (0)