aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Resig <jeresig@gmail.com>2007-03-25 20:30:16 +0000
committerJohn Resig <jeresig@gmail.com>2007-03-25 20:30:16 +0000
commit3446c3af764c4d91f3676b214575168b82205e83 (patch)
tree116fcd1ec3929c5d04231990619fd2066012eaa4 /src
parent44769df602f4b6a5152233d32eb2f93e71475bfe (diff)
downloadjquery-3446c3af764c4d91f3676b214575168b82205e83.tar.gz
jquery-3446c3af764c4d91f3676b214575168b82205e83.zip
Opera is also vulnerable to the getElementById-returning-name issue, fixed it there as well. Also had to tweak the UTF8 regexps to work in Safari (Safari doesn't support \uXXXX in RegExps, lame.)
Diffstat (limited to 'src')
-rw-r--r--src/selector/selector.js13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/selector/selector.js b/src/selector/selector.js
index b754d421e..d7fe9065a 100644
--- a/src/selector/selector.js
+++ b/src/selector/selector.js
@@ -76,7 +76,8 @@ jQuery.extend({
/^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,
// Match: :even, :last-chlid, #id, .class
- /^([:.#]*)((?:[\w\u0128-\uFFFF*-]|\\.)+)/
+ new RegExp("^([:.#]*)(" +
+ ( jQuery.chars = "(?:[\\w\u0128-\uFFFF*-]|\\\\.)" ) + "+)")
],
token: [
@@ -204,7 +205,7 @@ jQuery.extend({
} else {
// Optomize for the case nodeName#idName
- var re2 = /^(\w+)(#)((?:[\w\u0128-\uFFFF*-]|\\.)+)/;
+ var re2 = new RegExp("^(\\w+)(#)(" + jQuery.chars + "+)");
var m = re2.exec(t);
// Re-organize the results, so that they're consistent
@@ -214,7 +215,7 @@ jQuery.extend({
} else {
// Otherwise, do a traditional filter check for
// ID, class, and element selectors
- re2 = /^([#.]?)((?:[\w\u0128-\uFFFF*-]|\\.)*)/;
+ re2 = new RegExp("^([#.]?)(" + jQuery.chars + "*)");
m = re2.exec(t);
}
@@ -229,7 +230,7 @@ jQuery.extend({
// Do a quick check for the existence of the actual ID attribute
// to avoid selecting by the name attribute in IE
- if ( jQuery.browser.msie && oid && oid.id != m[2] )
+ if ( (jQuery.browser.msie||jQuery.browser.opera) && oid && oid.id != m[2] )
oid = jQuery('[@id="'+m[2]+'"]', elem)[0];
// Do a quick check for node name (where applicable) so
@@ -237,9 +238,7 @@ jQuery.extend({
ret = r = oid && (!m[3] || jQuery.nodeName(oid, m[3])) ? [oid] : [];
} else {
- // We need to find all descendant elements, it is more
- // efficient to use getAll() when we are already further down
- // the tree - we try to recognize that here
+ // We need to find all descendant elements
for ( var i = 0, rl = ret.length; i < rl; i++ ) {
// Grab the tag name being searched for
var tag = m[1] != "" || m[0] == "" ? "*" : m[2];