From f0189d618181409ac628b9bbdecd77338127b9b1 Mon Sep 17 00:00:00 2001 From: John Resig Date: Sun, 15 Feb 2009 22:46:54 +0000 Subject: [PATCH] Fixed the issue where weird characters were being used in ID selectors. Fixes jQuery bug #3913. --- src/selector.js | 2 +- test/index.html | 1 + test/unit/selector.js | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/selector.js b/src/selector.js index 4177672eb5..42e7e415e1 100644 --- a/src/selector.js +++ b/src/selector.js @@ -6,7 +6,7 @@ */ (function(){ -var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[]+)+|[>+~])(\s*,\s*)?/g, +var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g, done = 0, toString = Object.prototype.toString; diff --git a/test/index.html b/test/index.html index c415d11c60..e0389ac84e 100644 --- a/test/index.html +++ b/test/index.html @@ -50,6 +50,7 @@

This link has class="blog": Simon Willison's Weblog

+

Try them out:

    diff --git a/test/unit/selector.js b/test/unit/selector.js index 419116e6db..341d59b9e0 100644 --- a/test/unit/selector.js +++ b/test/unit/selector.js @@ -69,7 +69,7 @@ test("broken", function() { }); test("id", function() { - expect(27); + expect(28); t( "ID Selector", "#body", ["body"] ); t( "ID Selector w/ Element", "body#body", ["body"] ); t( "ID Selector w/ Element", "ul#first", [] ); @@ -105,6 +105,8 @@ test("id", function() { t( "Underscore ID", "#types_all", ["types_all"] ); t( "Dash ID", "#fx-queue", ["fx-queue"] ); + + t( "ID with weird characters in it", "#name\\+value", ["name+value"] ); }); test("class", function() {