1 | <html> |
---|
2 | <head> |
---|
3 | <script src="http://code.jquery.com/jquery-1.4.2.min.js"></script> |
---|
4 | <script type="text/javascript"> |
---|
5 | function applyPatch() { |
---|
6 | var Expr = jQuery.expr; |
---|
7 | |
---|
8 | Expr.match = { |
---|
9 | ID: /#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/, |
---|
10 | CLASS: /^[^[]*\.((?:[\w\u00c0-\uFFFF_-]|\\.)+)/, |
---|
11 | NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF_-]|\\.)+)['"]*\]/, |
---|
12 | ATTR: /\[\s*((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/, |
---|
13 | TAG: /^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/, |
---|
14 | CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/, |
---|
15 | POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/, |
---|
16 | PSEUDO: /:((?:[\w\u00c0-\uFFFF_-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/ |
---|
17 | }; |
---|
18 | |
---|
19 | for ( var type in Expr.match ) { |
---|
20 | Expr.match[ type ] = new RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source ); |
---|
21 | Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, function(all, num){ |
---|
22 | return "\\" + (num - 0 + 1); |
---|
23 | })); |
---|
24 | } |
---|
25 | }; |
---|
26 | |
---|
27 | $(function(){ |
---|
28 | var selector = '[name="person.names[0]"]:visible'; |
---|
29 | alert('w\\o patch\n'+selector+': '+$(selector).length); |
---|
30 | applyPatch(); |
---|
31 | alert('\\w patch\n'+selector+': '+$(selector).length); |
---|
32 | }); |
---|
33 | |
---|
34 | |
---|
35 | </script> |
---|
36 | </head> |
---|
37 | <body> |
---|
38 | <input name="person.names[0]" type="text"/> |
---|
39 | </body> |
---|
40 | </html> |
---|