|
11 | 11 | * optional array of values. When provided, they will be escaped and |
12 | 12 | * inserted into the selector string properly escaped. i.e.: |
13 | 13 | * |
14 | | - * .match(':has(?)', [ 'foo' ], {}) |
15 | | - * |
| 14 | + * .match(':has(?)', [ 'foo' ], {}) |
| 15 | + * |
16 | 16 | * would result in the seclector ':has("foo")' being matched against {}. |
17 | 17 | * |
18 | 18 | * This feature makes dynamically generated selectors more readable. |
|
26 | 26 | * .forEach(selector, [ values ], object, callback) |
27 | 27 | * |
28 | 28 | * Like match, but rather than returning an array, invokes the provided |
29 | | - * callback once per match as the matches are discovered. |
30 | | - * |
31 | | - * .compile(selector, [ values ]) |
| 29 | + * callback once per match as the matches are discovered. |
| 30 | + * |
| 31 | + * .compile(selector, [ values ]) |
32 | 32 | * |
33 | 33 | * Parses the selector and compiles it to an internal form, and returns |
34 | 34 | * an object which contains the compiled selector and has two properties: |
|
37 | 37 | * use the compiled selector. |
38 | 38 | * |
39 | 39 | * For cases where a complex selector is repeatedly used, this method |
40 | | - * should be faster as it will avoid recompiling the selector each time. |
| 40 | + * should be faster as it will avoid recompiling the selector each time. |
41 | 41 | */ |
42 | 42 | (function(exports) { |
43 | 43 |
|
|
110 | 110 | // (8) bogus JSON strings missing a trailing quote |
111 | 111 | "(\\\")|" + |
112 | 112 | // (9) identifiers (unquoted) |
113 | | - "\\.((?:[_a-zA-Z]|[^\\0-\\0177]|\\\\[^\\r\\n\\f0-9a-fA-F])(?:[\$_a-zA-Z0-9\\-]|[^\\u0000-\\u0177]|(?:\\\\[^\\r\\n\\f0-9a-fA-F]))*)" + |
| 113 | + "\\.((?:[_a-zA-Z]|[^\\0-\\0177]|\\\\[^\\r\\n\\f0-9a-fA-F])(?:[\\$_a-zA-Z0-9\\-]|[^\\u0000-\\u0177]|(?:\\\\[^\\r\\n\\f0-9a-fA-F]))*)" + |
114 | 114 | ")" |
115 | 115 | ); |
116 | 116 |
|
|
140 | 140 | // skip and don't capture leading whitespace |
141 | 141 | "^\\s*(?:" + |
142 | 142 | // (1) simple vals |
143 | | - "(true|false|null)|" + |
| 143 | + "(true|false|null)|" + |
144 | 144 | // (2) numbers |
145 | 145 | "(-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?)|" + |
146 | 146 | // (3) strings |
|
256 | 256 | if (!nested) hints = {}; |
257 | 257 |
|
258 | 258 | var a = [], am, readParen; |
259 | | - if (!off) off = 0; |
| 259 | + if (!off) off = 0; |
260 | 260 |
|
261 | 261 | while (true) { |
262 | 262 | var s = parse_selector(str, off, hints); |
|
543 | 543 | }); |
544 | 544 | if (arr.length) throw "too many parameters supplied"; |
545 | 545 | return sel; |
546 | | - } |
| 546 | + } |
547 | 547 |
|
548 | 548 | function compile(sel, arr) { |
549 | 549 | if (arr) sel = format(sel, arr); |
|
565 | 565 | return compile(sel, arr).match(obj); |
566 | 566 | }; |
567 | 567 | exports.forEach = function(sel, arr, obj, fun) { |
568 | | - if (!fun) { fun = obj; obj = arr; arr = undefined } |
| 568 | + if (!fun) { fun = obj; obj = arr; arr = undefined; } |
569 | 569 | return compile(sel, arr).forEach(obj, fun); |
570 | 570 | }; |
571 | 571 | exports.compile = compile; |
|
0 commit comments