parsejs 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rspec +1 -0
- data/.travis.yml +9 -0
- data/Gemfile +5 -0
- data/README.markdown +85 -0
- data/Rakefile +15 -0
- data/lib/parsejs.rb +14 -0
- data/lib/parsejs/ast.rb +84 -0
- data/lib/parsejs/docs.rb +237 -0
- data/lib/parsejs/grammar.kpeg +575 -0
- data/lib/parsejs/grammar.kpeg.rb +9460 -0
- data/lib/parsejs/scope.rb +183 -0
- data/lib/parsejs/stringifier.rb +450 -0
- data/lib/parsejs/version.rb +3 -0
- data/lib/parsejs/visitor.rb +257 -0
- data/parsejs.gemspec +24 -0
- data/spec/fixtures/jquery-1.6.js +8982 -0
- data/spec/fixtures/jquery-1.7.js +9289 -0
- data/spec/fixtures/jquery-ajax.js +1000 -0
- data/spec/fixtures/jquery-attributes.js +650 -0
- data/spec/fixtures/jquery-traversing.js +330 -0
- data/spec/fixtures/metamorph.js +324 -0
- data/spec/fixtures/sizzle.js +1442 -0
- data/spec/fixtures/sproutcore-core.js +195 -0
- data/spec/fixtures/sproutcore-each-proxy.js +218 -0
- data/spec/fixtures/sproutcore-native-array.js +139 -0
- data/spec/fixtures/sproutcore.js +14319 -0
- data/spec/scope_spec.rb +111 -0
- data/spec/stringify_spec.rb +587 -0
- data/test.rb +76 -0
- metadata +145 -0
@@ -0,0 +1,1442 @@
|
|
1
|
+
/*!
|
2
|
+
* Sizzle CSS Selector Engine
|
3
|
+
* Copyright 2011, The Dojo Foundation
|
4
|
+
* Released under the MIT, BSD, and GPL Licenses.
|
5
|
+
* More information: http://sizzlejs.com/
|
6
|
+
*/
|
7
|
+
(function(){
|
8
|
+
|
9
|
+
var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
|
10
|
+
expando = "sizcache" + (Math.random() + '').replace('.', ''),
|
11
|
+
done = 0,
|
12
|
+
toString = Object.prototype.toString,
|
13
|
+
hasDuplicate = false,
|
14
|
+
baseHasDuplicate = true,
|
15
|
+
rBackslash = /\\/g,
|
16
|
+
rReturn = /\r\n/g,
|
17
|
+
rNonWord = /\W/;
|
18
|
+
|
19
|
+
// Here we check if the JavaScript engine is using some sort of
|
20
|
+
// optimization where it does not always call our comparision
|
21
|
+
// function. If that is the case, discard the hasDuplicate value.
|
22
|
+
// Thus far that includes Google Chrome.
|
23
|
+
[0, 0].sort(function() {
|
24
|
+
baseHasDuplicate = false;
|
25
|
+
return 0;
|
26
|
+
});
|
27
|
+
|
28
|
+
var Sizzle = function( selector, context, results, seed ) {
|
29
|
+
results = results || [];
|
30
|
+
context = context || document;
|
31
|
+
|
32
|
+
var origContext = context;
|
33
|
+
|
34
|
+
if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
|
35
|
+
return [];
|
36
|
+
}
|
37
|
+
|
38
|
+
if ( !selector || typeof selector !== "string" ) {
|
39
|
+
return results;
|
40
|
+
}
|
41
|
+
|
42
|
+
var m, set, checkSet, extra, ret, cur, pop, i,
|
43
|
+
prune = true,
|
44
|
+
contextXML = Sizzle.isXML( context ),
|
45
|
+
parts = [],
|
46
|
+
soFar = selector;
|
47
|
+
|
48
|
+
// Reset the position of the chunker regexp (start from head)
|
49
|
+
do {
|
50
|
+
chunker.exec( "" );
|
51
|
+
m = chunker.exec( soFar );
|
52
|
+
|
53
|
+
if ( m ) {
|
54
|
+
soFar = m[3];
|
55
|
+
|
56
|
+
parts.push( m[1] );
|
57
|
+
|
58
|
+
if ( m[2] ) {
|
59
|
+
extra = m[3];
|
60
|
+
break;
|
61
|
+
}
|
62
|
+
}
|
63
|
+
} while ( m );
|
64
|
+
|
65
|
+
if ( parts.length > 1 && origPOS.exec( selector ) ) {
|
66
|
+
|
67
|
+
if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
|
68
|
+
set = posProcess( parts[0] + parts[1], context, seed );
|
69
|
+
|
70
|
+
} else {
|
71
|
+
set = Expr.relative[ parts[0] ] ?
|
72
|
+
[ context ] :
|
73
|
+
Sizzle( parts.shift(), context );
|
74
|
+
|
75
|
+
while ( parts.length ) {
|
76
|
+
selector = parts.shift();
|
77
|
+
|
78
|
+
if ( Expr.relative[ selector ] ) {
|
79
|
+
selector += parts.shift();
|
80
|
+
}
|
81
|
+
|
82
|
+
set = posProcess( selector, set, seed );
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
} else {
|
87
|
+
// Take a shortcut and set the context if the root selector is an ID
|
88
|
+
// (but not if it'll be faster if the inner selector is an ID)
|
89
|
+
if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
|
90
|
+
Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
|
91
|
+
|
92
|
+
ret = Sizzle.find( parts.shift(), context, contextXML );
|
93
|
+
context = ret.expr ?
|
94
|
+
Sizzle.filter( ret.expr, ret.set )[0] :
|
95
|
+
ret.set[0];
|
96
|
+
}
|
97
|
+
|
98
|
+
if ( context ) {
|
99
|
+
ret = seed ?
|
100
|
+
{ expr: parts.pop(), set: makeArray(seed) } :
|
101
|
+
Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
|
102
|
+
|
103
|
+
set = ret.expr ?
|
104
|
+
Sizzle.filter( ret.expr, ret.set ) :
|
105
|
+
ret.set;
|
106
|
+
|
107
|
+
if ( parts.length > 0 ) {
|
108
|
+
checkSet = makeArray( set );
|
109
|
+
|
110
|
+
} else {
|
111
|
+
prune = false;
|
112
|
+
}
|
113
|
+
|
114
|
+
while ( parts.length ) {
|
115
|
+
cur = parts.pop();
|
116
|
+
pop = cur;
|
117
|
+
|
118
|
+
if ( !Expr.relative[ cur ] ) {
|
119
|
+
cur = "";
|
120
|
+
} else {
|
121
|
+
pop = parts.pop();
|
122
|
+
}
|
123
|
+
|
124
|
+
if ( pop == null ) {
|
125
|
+
pop = context;
|
126
|
+
}
|
127
|
+
|
128
|
+
Expr.relative[ cur ]( checkSet, pop, contextXML );
|
129
|
+
}
|
130
|
+
|
131
|
+
} else {
|
132
|
+
checkSet = parts = [];
|
133
|
+
}
|
134
|
+
}
|
135
|
+
|
136
|
+
if ( !checkSet ) {
|
137
|
+
checkSet = set;
|
138
|
+
}
|
139
|
+
|
140
|
+
if ( !checkSet ) {
|
141
|
+
Sizzle.error( cur || selector );
|
142
|
+
}
|
143
|
+
|
144
|
+
if ( toString.call(checkSet) === "[object Array]" ) {
|
145
|
+
if ( !prune ) {
|
146
|
+
results.push.apply( results, checkSet );
|
147
|
+
|
148
|
+
} else if ( context && context.nodeType === 1 ) {
|
149
|
+
for ( i = 0; checkSet[i] != null; i++ ) {
|
150
|
+
if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) {
|
151
|
+
results.push( set[i] );
|
152
|
+
}
|
153
|
+
}
|
154
|
+
|
155
|
+
} else {
|
156
|
+
for ( i = 0; checkSet[i] != null; i++ ) {
|
157
|
+
if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
|
158
|
+
results.push( set[i] );
|
159
|
+
}
|
160
|
+
}
|
161
|
+
}
|
162
|
+
|
163
|
+
} else {
|
164
|
+
makeArray( checkSet, results );
|
165
|
+
}
|
166
|
+
|
167
|
+
if ( extra ) {
|
168
|
+
Sizzle( extra, origContext, results, seed );
|
169
|
+
Sizzle.uniqueSort( results );
|
170
|
+
}
|
171
|
+
|
172
|
+
return results;
|
173
|
+
};
|
174
|
+
|
175
|
+
Sizzle.uniqueSort = function( results ) {
|
176
|
+
if ( sortOrder ) {
|
177
|
+
hasDuplicate = baseHasDuplicate;
|
178
|
+
results.sort( sortOrder );
|
179
|
+
|
180
|
+
if ( hasDuplicate ) {
|
181
|
+
for ( var i = 1; i < results.length; i++ ) {
|
182
|
+
if ( results[i] === results[ i - 1 ] ) {
|
183
|
+
results.splice( i--, 1 );
|
184
|
+
}
|
185
|
+
}
|
186
|
+
}
|
187
|
+
}
|
188
|
+
|
189
|
+
return results;
|
190
|
+
};
|
191
|
+
|
192
|
+
Sizzle.matches = function( expr, set ) {
|
193
|
+
return Sizzle( expr, null, null, set );
|
194
|
+
};
|
195
|
+
|
196
|
+
Sizzle.matchesSelector = function( node, expr ) {
|
197
|
+
return Sizzle( expr, null, null, [node] ).length > 0;
|
198
|
+
};
|
199
|
+
|
200
|
+
Sizzle.find = function( expr, context, isXML ) {
|
201
|
+
var set, i, len, match, type, left;
|
202
|
+
|
203
|
+
if ( !expr ) {
|
204
|
+
return [];
|
205
|
+
}
|
206
|
+
|
207
|
+
for ( i = 0, len = Expr.order.length; i < len; i++ ) {
|
208
|
+
type = Expr.order[i];
|
209
|
+
|
210
|
+
if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
|
211
|
+
left = match[1];
|
212
|
+
match.splice( 1, 1 );
|
213
|
+
|
214
|
+
if ( left.substr( left.length - 1 ) !== "\\" ) {
|
215
|
+
match[1] = (match[1] || "").replace( rBackslash, "" );
|
216
|
+
set = Expr.find[ type ]( match, context, isXML );
|
217
|
+
|
218
|
+
if ( set != null ) {
|
219
|
+
expr = expr.replace( Expr.match[ type ], "" );
|
220
|
+
break;
|
221
|
+
}
|
222
|
+
}
|
223
|
+
}
|
224
|
+
}
|
225
|
+
|
226
|
+
if ( !set ) {
|
227
|
+
set = typeof context.getElementsByTagName !== "undefined" ?
|
228
|
+
context.getElementsByTagName( "*" ) :
|
229
|
+
[];
|
230
|
+
}
|
231
|
+
|
232
|
+
return { set: set, expr: expr };
|
233
|
+
};
|
234
|
+
|
235
|
+
Sizzle.filter = function( expr, set, inplace, not ) {
|
236
|
+
var match, anyFound,
|
237
|
+
type, found, item, filter, left,
|
238
|
+
i, pass,
|
239
|
+
old = expr,
|
240
|
+
result = [],
|
241
|
+
curLoop = set,
|
242
|
+
isXMLFilter = set && set[0] && Sizzle.isXML( set[0] );
|
243
|
+
|
244
|
+
while ( expr && set.length ) {
|
245
|
+
for ( type in Expr.filter ) {
|
246
|
+
if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
|
247
|
+
filter = Expr.filter[ type ];
|
248
|
+
left = match[1];
|
249
|
+
|
250
|
+
anyFound = false;
|
251
|
+
|
252
|
+
match.splice(1,1);
|
253
|
+
|
254
|
+
if ( left.substr( left.length - 1 ) === "\\" ) {
|
255
|
+
continue;
|
256
|
+
}
|
257
|
+
|
258
|
+
if ( curLoop === result ) {
|
259
|
+
result = [];
|
260
|
+
}
|
261
|
+
|
262
|
+
if ( Expr.preFilter[ type ] ) {
|
263
|
+
match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
|
264
|
+
|
265
|
+
if ( !match ) {
|
266
|
+
anyFound = found = true;
|
267
|
+
|
268
|
+
} else if ( match === true ) {
|
269
|
+
continue;
|
270
|
+
}
|
271
|
+
}
|
272
|
+
|
273
|
+
if ( match ) {
|
274
|
+
for ( i = 0; (item = curLoop[i]) != null; i++ ) {
|
275
|
+
if ( item ) {
|
276
|
+
found = filter( item, match, i, curLoop );
|
277
|
+
pass = not ^ found;
|
278
|
+
|
279
|
+
if ( inplace && found != null ) {
|
280
|
+
if ( pass ) {
|
281
|
+
anyFound = true;
|
282
|
+
|
283
|
+
} else {
|
284
|
+
curLoop[i] = false;
|
285
|
+
}
|
286
|
+
|
287
|
+
} else if ( pass ) {
|
288
|
+
result.push( item );
|
289
|
+
anyFound = true;
|
290
|
+
}
|
291
|
+
}
|
292
|
+
}
|
293
|
+
}
|
294
|
+
|
295
|
+
if ( found !== undefined ) {
|
296
|
+
if ( !inplace ) {
|
297
|
+
curLoop = result;
|
298
|
+
}
|
299
|
+
|
300
|
+
expr = expr.replace( Expr.match[ type ], "" );
|
301
|
+
|
302
|
+
if ( !anyFound ) {
|
303
|
+
return [];
|
304
|
+
}
|
305
|
+
|
306
|
+
break;
|
307
|
+
}
|
308
|
+
}
|
309
|
+
}
|
310
|
+
|
311
|
+
// Improper expression
|
312
|
+
if ( expr === old ) {
|
313
|
+
if ( anyFound == null ) {
|
314
|
+
Sizzle.error( expr );
|
315
|
+
|
316
|
+
} else {
|
317
|
+
break;
|
318
|
+
}
|
319
|
+
}
|
320
|
+
|
321
|
+
old = expr;
|
322
|
+
}
|
323
|
+
|
324
|
+
return curLoop;
|
325
|
+
};
|
326
|
+
|
327
|
+
Sizzle.error = function( msg ) {
|
328
|
+
throw "Syntax error, unrecognized expression: " + msg;
|
329
|
+
};
|
330
|
+
|
331
|
+
/**
|
332
|
+
* Utility function for retreiving the text value of an array of DOM nodes
|
333
|
+
* @param {Array|Element} elem
|
334
|
+
*/
|
335
|
+
var getText = Sizzle.getText = function( elem ) {
|
336
|
+
var i, node,
|
337
|
+
nodeType = elem.nodeType,
|
338
|
+
ret = "";
|
339
|
+
|
340
|
+
if ( nodeType ) {
|
341
|
+
if ( nodeType === 1 ) {
|
342
|
+
// Use textContent || innerText for elements
|
343
|
+
if ( typeof elem.textContent === 'string' ) {
|
344
|
+
return elem.textContent;
|
345
|
+
} else if ( typeof elem.innerText === 'string' ) {
|
346
|
+
// Replace IE's carriage returns
|
347
|
+
return elem.innerText.replace( rReturn, '' );
|
348
|
+
} else {
|
349
|
+
// Traverse it's children
|
350
|
+
for ( elem = elem.firstChild; elem; elem = elem.nextSibling) {
|
351
|
+
ret += getText( elem );
|
352
|
+
}
|
353
|
+
}
|
354
|
+
} else if ( nodeType === 3 || nodeType === 4 ) {
|
355
|
+
return elem.nodeValue;
|
356
|
+
}
|
357
|
+
} else {
|
358
|
+
|
359
|
+
// If no nodeType, this is expected to be an array
|
360
|
+
for ( i = 0; (node = elem[i]); i++ ) {
|
361
|
+
// Do not traverse comment nodes
|
362
|
+
if ( node.nodeType !== 8 ) {
|
363
|
+
ret += getText( node );
|
364
|
+
}
|
365
|
+
}
|
366
|
+
}
|
367
|
+
return ret;
|
368
|
+
};
|
369
|
+
|
370
|
+
var Expr = Sizzle.selectors = {
|
371
|
+
order: [ "ID", "NAME", "TAG" ],
|
372
|
+
|
373
|
+
match: {
|
374
|
+
ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
|
375
|
+
CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
|
376
|
+
NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
|
377
|
+
ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,
|
378
|
+
TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
|
379
|
+
CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,
|
380
|
+
POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
|
381
|
+
PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
|
382
|
+
},
|
383
|
+
|
384
|
+
leftMatch: {},
|
385
|
+
|
386
|
+
attrMap: {
|
387
|
+
"class": "className",
|
388
|
+
"for": "htmlFor"
|
389
|
+
},
|
390
|
+
|
391
|
+
attrHandle: {
|
392
|
+
href: function( elem ) {
|
393
|
+
return elem.getAttribute( "href" );
|
394
|
+
},
|
395
|
+
type: function( elem ) {
|
396
|
+
return elem.getAttribute( "type" );
|
397
|
+
}
|
398
|
+
},
|
399
|
+
|
400
|
+
relative: {
|
401
|
+
"+": function(checkSet, part){
|
402
|
+
var isPartStr = typeof part === "string",
|
403
|
+
isTag = isPartStr && !rNonWord.test( part ),
|
404
|
+
isPartStrNotTag = isPartStr && !isTag;
|
405
|
+
|
406
|
+
if ( isTag ) {
|
407
|
+
part = part.toLowerCase();
|
408
|
+
}
|
409
|
+
|
410
|
+
for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
|
411
|
+
if ( (elem = checkSet[i]) ) {
|
412
|
+
while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
|
413
|
+
|
414
|
+
checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
|
415
|
+
elem || false :
|
416
|
+
elem === part;
|
417
|
+
}
|
418
|
+
}
|
419
|
+
|
420
|
+
if ( isPartStrNotTag ) {
|
421
|
+
Sizzle.filter( part, checkSet, true );
|
422
|
+
}
|
423
|
+
},
|
424
|
+
|
425
|
+
">": function( checkSet, part ) {
|
426
|
+
var elem,
|
427
|
+
isPartStr = typeof part === "string",
|
428
|
+
i = 0,
|
429
|
+
l = checkSet.length;
|
430
|
+
|
431
|
+
if ( isPartStr && !rNonWord.test( part ) ) {
|
432
|
+
part = part.toLowerCase();
|
433
|
+
|
434
|
+
for ( ; i < l; i++ ) {
|
435
|
+
elem = checkSet[i];
|
436
|
+
|
437
|
+
if ( elem ) {
|
438
|
+
var parent = elem.parentNode;
|
439
|
+
checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
|
440
|
+
}
|
441
|
+
}
|
442
|
+
|
443
|
+
} else {
|
444
|
+
for ( ; i < l; i++ ) {
|
445
|
+
elem = checkSet[i];
|
446
|
+
|
447
|
+
if ( elem ) {
|
448
|
+
checkSet[i] = isPartStr ?
|
449
|
+
elem.parentNode :
|
450
|
+
elem.parentNode === part;
|
451
|
+
}
|
452
|
+
}
|
453
|
+
|
454
|
+
if ( isPartStr ) {
|
455
|
+
Sizzle.filter( part, checkSet, true );
|
456
|
+
}
|
457
|
+
}
|
458
|
+
},
|
459
|
+
|
460
|
+
"": function(checkSet, part, isXML){
|
461
|
+
var nodeCheck,
|
462
|
+
doneName = done++,
|
463
|
+
checkFn = dirCheck;
|
464
|
+
|
465
|
+
if ( typeof part === "string" && !rNonWord.test( part ) ) {
|
466
|
+
part = part.toLowerCase();
|
467
|
+
nodeCheck = part;
|
468
|
+
checkFn = dirNodeCheck;
|
469
|
+
}
|
470
|
+
|
471
|
+
checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML );
|
472
|
+
},
|
473
|
+
|
474
|
+
"~": function( checkSet, part, isXML ) {
|
475
|
+
var nodeCheck,
|
476
|
+
doneName = done++,
|
477
|
+
checkFn = dirCheck;
|
478
|
+
|
479
|
+
if ( typeof part === "string" && !rNonWord.test( part ) ) {
|
480
|
+
part = part.toLowerCase();
|
481
|
+
nodeCheck = part;
|
482
|
+
checkFn = dirNodeCheck;
|
483
|
+
}
|
484
|
+
|
485
|
+
checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML );
|
486
|
+
}
|
487
|
+
},
|
488
|
+
|
489
|
+
find: {
|
490
|
+
ID: function( match, context, isXML ) {
|
491
|
+
if ( typeof context.getElementById !== "undefined" && !isXML ) {
|
492
|
+
var m = context.getElementById(match[1]);
|
493
|
+
// Check parentNode to catch when Blackberry 4.6 returns
|
494
|
+
// nodes that are no longer in the document #6963
|
495
|
+
return m && m.parentNode ? [m] : [];
|
496
|
+
}
|
497
|
+
},
|
498
|
+
|
499
|
+
NAME: function( match, context ) {
|
500
|
+
if ( typeof context.getElementsByName !== "undefined" ) {
|
501
|
+
var ret = [],
|
502
|
+
results = context.getElementsByName( match[1] );
|
503
|
+
|
504
|
+
for ( var i = 0, l = results.length; i < l; i++ ) {
|
505
|
+
if ( results[i].getAttribute("name") === match[1] ) {
|
506
|
+
ret.push( results[i] );
|
507
|
+
}
|
508
|
+
}
|
509
|
+
|
510
|
+
return ret.length === 0 ? null : ret;
|
511
|
+
}
|
512
|
+
},
|
513
|
+
|
514
|
+
TAG: function( match, context ) {
|
515
|
+
if ( typeof context.getElementsByTagName !== "undefined" ) {
|
516
|
+
return context.getElementsByTagName( match[1] );
|
517
|
+
}
|
518
|
+
}
|
519
|
+
},
|
520
|
+
preFilter: {
|
521
|
+
CLASS: function( match, curLoop, inplace, result, not, isXML ) {
|
522
|
+
match = " " + match[1].replace( rBackslash, "" ) + " ";
|
523
|
+
|
524
|
+
if ( isXML ) {
|
525
|
+
return match;
|
526
|
+
}
|
527
|
+
|
528
|
+
for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
|
529
|
+
if ( elem ) {
|
530
|
+
if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) {
|
531
|
+
if ( !inplace ) {
|
532
|
+
result.push( elem );
|
533
|
+
}
|
534
|
+
|
535
|
+
} else if ( inplace ) {
|
536
|
+
curLoop[i] = false;
|
537
|
+
}
|
538
|
+
}
|
539
|
+
}
|
540
|
+
|
541
|
+
return false;
|
542
|
+
},
|
543
|
+
|
544
|
+
ID: function( match ) {
|
545
|
+
return match[1].replace( rBackslash, "" );
|
546
|
+
},
|
547
|
+
|
548
|
+
TAG: function( match, curLoop ) {
|
549
|
+
return match[1].replace( rBackslash, "" ).toLowerCase();
|
550
|
+
},
|
551
|
+
|
552
|
+
CHILD: function( match ) {
|
553
|
+
if ( match[1] === "nth" ) {
|
554
|
+
if ( !match[2] ) {
|
555
|
+
Sizzle.error( match[0] );
|
556
|
+
}
|
557
|
+
|
558
|
+
match[2] = match[2].replace(/^\+|\s*/g, '');
|
559
|
+
|
560
|
+
// parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
|
561
|
+
var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec(
|
562
|
+
match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
|
563
|
+
!/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
|
564
|
+
|
565
|
+
// calculate the numbers (first)n+(last) including if they are negative
|
566
|
+
match[2] = (test[1] + (test[2] || 1)) - 0;
|
567
|
+
match[3] = test[3] - 0;
|
568
|
+
}
|
569
|
+
else if ( match[2] ) {
|
570
|
+
Sizzle.error( match[0] );
|
571
|
+
}
|
572
|
+
|
573
|
+
// TODO: Move to normal caching system
|
574
|
+
match[0] = done++;
|
575
|
+
|
576
|
+
return match;
|
577
|
+
},
|
578
|
+
|
579
|
+
ATTR: function( match, curLoop, inplace, result, not, isXML ) {
|
580
|
+
var name = match[1] = match[1].replace( rBackslash, "" );
|
581
|
+
|
582
|
+
if ( !isXML && Expr.attrMap[name] ) {
|
583
|
+
match[1] = Expr.attrMap[name];
|
584
|
+
}
|
585
|
+
|
586
|
+
// Handle if an un-quoted value was used
|
587
|
+
match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" );
|
588
|
+
|
589
|
+
if ( match[2] === "~=" ) {
|
590
|
+
match[4] = " " + match[4] + " ";
|
591
|
+
}
|
592
|
+
|
593
|
+
return match;
|
594
|
+
},
|
595
|
+
|
596
|
+
PSEUDO: function( match, curLoop, inplace, result, not ) {
|
597
|
+
if ( match[1] === "not" ) {
|
598
|
+
// If we're dealing with a complex expression, or a simple one
|
599
|
+
if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
|
600
|
+
match[3] = Sizzle(match[3], null, null, curLoop);
|
601
|
+
|
602
|
+
} else {
|
603
|
+
var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
|
604
|
+
|
605
|
+
if ( !inplace ) {
|
606
|
+
result.push.apply( result, ret );
|
607
|
+
}
|
608
|
+
|
609
|
+
return false;
|
610
|
+
}
|
611
|
+
|
612
|
+
} else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
|
613
|
+
return true;
|
614
|
+
}
|
615
|
+
|
616
|
+
return match;
|
617
|
+
},
|
618
|
+
|
619
|
+
POS: function( match ) {
|
620
|
+
match.unshift( true );
|
621
|
+
|
622
|
+
return match;
|
623
|
+
}
|
624
|
+
},
|
625
|
+
|
626
|
+
filters: {
|
627
|
+
enabled: function( elem ) {
|
628
|
+
return elem.disabled === false && elem.type !== "hidden";
|
629
|
+
},
|
630
|
+
|
631
|
+
disabled: function( elem ) {
|
632
|
+
return elem.disabled === true;
|
633
|
+
},
|
634
|
+
|
635
|
+
checked: function( elem ) {
|
636
|
+
return elem.checked === true;
|
637
|
+
},
|
638
|
+
|
639
|
+
selected: function( elem ) {
|
640
|
+
// Accessing this property makes selected-by-default
|
641
|
+
// options in Safari work properly
|
642
|
+
if ( elem.parentNode ) {
|
643
|
+
elem.parentNode.selectedIndex;
|
644
|
+
}
|
645
|
+
|
646
|
+
return elem.selected === true;
|
647
|
+
},
|
648
|
+
|
649
|
+
parent: function( elem ) {
|
650
|
+
return !!elem.firstChild;
|
651
|
+
},
|
652
|
+
|
653
|
+
empty: function( elem ) {
|
654
|
+
return !elem.firstChild;
|
655
|
+
},
|
656
|
+
|
657
|
+
has: function( elem, i, match ) {
|
658
|
+
return !!Sizzle( match[3], elem ).length;
|
659
|
+
},
|
660
|
+
|
661
|
+
header: function( elem ) {
|
662
|
+
return (/h\d/i).test( elem.nodeName );
|
663
|
+
},
|
664
|
+
|
665
|
+
text: function( elem ) {
|
666
|
+
var attr = elem.getAttribute( "type" ), type = elem.type;
|
667
|
+
// IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
|
668
|
+
// use getAttribute instead to test this case
|
669
|
+
return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null );
|
670
|
+
},
|
671
|
+
|
672
|
+
radio: function( elem ) {
|
673
|
+
return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type;
|
674
|
+
},
|
675
|
+
|
676
|
+
checkbox: function( elem ) {
|
677
|
+
return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type;
|
678
|
+
},
|
679
|
+
|
680
|
+
file: function( elem ) {
|
681
|
+
return elem.nodeName.toLowerCase() === "input" && "file" === elem.type;
|
682
|
+
},
|
683
|
+
|
684
|
+
password: function( elem ) {
|
685
|
+
return elem.nodeName.toLowerCase() === "input" && "password" === elem.type;
|
686
|
+
},
|
687
|
+
|
688
|
+
submit: function( elem ) {
|
689
|
+
var name = elem.nodeName.toLowerCase();
|
690
|
+
return (name === "input" || name === "button") && "submit" === elem.type;
|
691
|
+
},
|
692
|
+
|
693
|
+
image: function( elem ) {
|
694
|
+
return elem.nodeName.toLowerCase() === "input" && "image" === elem.type;
|
695
|
+
},
|
696
|
+
|
697
|
+
reset: function( elem ) {
|
698
|
+
var name = elem.nodeName.toLowerCase();
|
699
|
+
return (name === "input" || name === "button") && "reset" === elem.type;
|
700
|
+
},
|
701
|
+
|
702
|
+
button: function( elem ) {
|
703
|
+
var name = elem.nodeName.toLowerCase();
|
704
|
+
return name === "input" && "button" === elem.type || name === "button";
|
705
|
+
},
|
706
|
+
|
707
|
+
input: function( elem ) {
|
708
|
+
return (/input|select|textarea|button/i).test( elem.nodeName );
|
709
|
+
},
|
710
|
+
|
711
|
+
focus: function( elem ) {
|
712
|
+
return elem === elem.ownerDocument.activeElement;
|
713
|
+
}
|
714
|
+
},
|
715
|
+
setFilters: {
|
716
|
+
first: function( elem, i ) {
|
717
|
+
return i === 0;
|
718
|
+
},
|
719
|
+
|
720
|
+
last: function( elem, i, match, array ) {
|
721
|
+
return i === array.length - 1;
|
722
|
+
},
|
723
|
+
|
724
|
+
even: function( elem, i ) {
|
725
|
+
return i % 2 === 0;
|
726
|
+
},
|
727
|
+
|
728
|
+
odd: function( elem, i ) {
|
729
|
+
return i % 2 === 1;
|
730
|
+
},
|
731
|
+
|
732
|
+
lt: function( elem, i, match ) {
|
733
|
+
return i < match[3] - 0;
|
734
|
+
},
|
735
|
+
|
736
|
+
gt: function( elem, i, match ) {
|
737
|
+
return i > match[3] - 0;
|
738
|
+
},
|
739
|
+
|
740
|
+
nth: function( elem, i, match ) {
|
741
|
+
return match[3] - 0 === i;
|
742
|
+
},
|
743
|
+
|
744
|
+
eq: function( elem, i, match ) {
|
745
|
+
return match[3] - 0 === i;
|
746
|
+
}
|
747
|
+
},
|
748
|
+
filter: {
|
749
|
+
PSEUDO: function( elem, match, i, array ) {
|
750
|
+
var name = match[1],
|
751
|
+
filter = Expr.filters[ name ];
|
752
|
+
|
753
|
+
if ( filter ) {
|
754
|
+
return filter( elem, i, match, array );
|
755
|
+
|
756
|
+
} else if ( name === "contains" ) {
|
757
|
+
return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0;
|
758
|
+
|
759
|
+
} else if ( name === "not" ) {
|
760
|
+
var not = match[3];
|
761
|
+
|
762
|
+
for ( var j = 0, l = not.length; j < l; j++ ) {
|
763
|
+
if ( not[j] === elem ) {
|
764
|
+
return false;
|
765
|
+
}
|
766
|
+
}
|
767
|
+
|
768
|
+
return true;
|
769
|
+
|
770
|
+
} else {
|
771
|
+
Sizzle.error( name );
|
772
|
+
}
|
773
|
+
},
|
774
|
+
|
775
|
+
CHILD: function( elem, match ) {
|
776
|
+
var first, last,
|
777
|
+
doneName, parent, cache,
|
778
|
+
count, diff,
|
779
|
+
type = match[1],
|
780
|
+
node = elem;
|
781
|
+
|
782
|
+
switch ( type ) {
|
783
|
+
case "only":
|
784
|
+
case "first":
|
785
|
+
while ( (node = node.previousSibling) ) {
|
786
|
+
if ( node.nodeType === 1 ) {
|
787
|
+
return false;
|
788
|
+
}
|
789
|
+
}
|
790
|
+
|
791
|
+
if ( type === "first" ) {
|
792
|
+
return true;
|
793
|
+
}
|
794
|
+
|
795
|
+
node = elem;
|
796
|
+
|
797
|
+
case "last":
|
798
|
+
while ( (node = node.nextSibling) ) {
|
799
|
+
if ( node.nodeType === 1 ) {
|
800
|
+
return false;
|
801
|
+
}
|
802
|
+
}
|
803
|
+
|
804
|
+
return true;
|
805
|
+
|
806
|
+
case "nth":
|
807
|
+
first = match[2];
|
808
|
+
last = match[3];
|
809
|
+
|
810
|
+
if ( first === 1 && last === 0 ) {
|
811
|
+
return true;
|
812
|
+
}
|
813
|
+
|
814
|
+
doneName = match[0];
|
815
|
+
parent = elem.parentNode;
|
816
|
+
|
817
|
+
if ( parent && (parent[ expando ] !== doneName || !elem.nodeIndex) ) {
|
818
|
+
count = 0;
|
819
|
+
|
820
|
+
for ( node = parent.firstChild; node; node = node.nextSibling ) {
|
821
|
+
if ( node.nodeType === 1 ) {
|
822
|
+
node.nodeIndex = ++count;
|
823
|
+
}
|
824
|
+
}
|
825
|
+
|
826
|
+
parent[ expando ] = doneName;
|
827
|
+
}
|
828
|
+
|
829
|
+
diff = elem.nodeIndex - last;
|
830
|
+
|
831
|
+
if ( first === 0 ) {
|
832
|
+
return diff === 0;
|
833
|
+
|
834
|
+
} else {
|
835
|
+
return ( diff % first === 0 && diff / first >= 0 );
|
836
|
+
}
|
837
|
+
}
|
838
|
+
},
|
839
|
+
|
840
|
+
ID: function( elem, match ) {
|
841
|
+
return elem.nodeType === 1 && elem.getAttribute("id") === match;
|
842
|
+
},
|
843
|
+
|
844
|
+
TAG: function( elem, match ) {
|
845
|
+
return (match === "*" && elem.nodeType === 1) || !!elem.nodeName && elem.nodeName.toLowerCase() === match;
|
846
|
+
},
|
847
|
+
|
848
|
+
CLASS: function( elem, match ) {
|
849
|
+
return (" " + (elem.className || elem.getAttribute("class")) + " ")
|
850
|
+
.indexOf( match ) > -1;
|
851
|
+
},
|
852
|
+
|
853
|
+
ATTR: function( elem, match ) {
|
854
|
+
var name = match[1],
|
855
|
+
result = Sizzle.attr ?
|
856
|
+
Sizzle.attr( elem, name ) :
|
857
|
+
Expr.attrHandle[ name ] ?
|
858
|
+
Expr.attrHandle[ name ]( elem ) :
|
859
|
+
elem[ name ] != null ?
|
860
|
+
elem[ name ] :
|
861
|
+
elem.getAttribute( name ),
|
862
|
+
value = result + "",
|
863
|
+
type = match[2],
|
864
|
+
check = match[4];
|
865
|
+
|
866
|
+
return result == null ?
|
867
|
+
type === "!=" :
|
868
|
+
!type && Sizzle.attr ?
|
869
|
+
result != null :
|
870
|
+
type === "=" ?
|
871
|
+
value === check :
|
872
|
+
type === "*=" ?
|
873
|
+
value.indexOf(check) >= 0 :
|
874
|
+
type === "~=" ?
|
875
|
+
(" " + value + " ").indexOf(check) >= 0 :
|
876
|
+
!check ?
|
877
|
+
value && result !== false :
|
878
|
+
type === "!=" ?
|
879
|
+
value !== check :
|
880
|
+
type === "^=" ?
|
881
|
+
value.indexOf(check) === 0 :
|
882
|
+
type === "$=" ?
|
883
|
+
value.substr(value.length - check.length) === check :
|
884
|
+
type === "|=" ?
|
885
|
+
value === check || value.substr(0, check.length + 1) === check + "-" :
|
886
|
+
false;
|
887
|
+
},
|
888
|
+
|
889
|
+
POS: function( elem, match, i, array ) {
|
890
|
+
var name = match[2],
|
891
|
+
filter = Expr.setFilters[ name ];
|
892
|
+
|
893
|
+
if ( filter ) {
|
894
|
+
return filter( elem, i, match, array );
|
895
|
+
}
|
896
|
+
}
|
897
|
+
}
|
898
|
+
};
|
899
|
+
|
900
|
+
var origPOS = Expr.match.POS,
|
901
|
+
fescape = function(all, num){
|
902
|
+
return "\\" + (num - 0 + 1);
|
903
|
+
};
|
904
|
+
|
905
|
+
for ( var type in Expr.match ) {
|
906
|
+
Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
|
907
|
+
Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
|
908
|
+
}
|
909
|
+
|
910
|
+
var makeArray = function( array, results ) {
|
911
|
+
array = Array.prototype.slice.call( array, 0 );
|
912
|
+
|
913
|
+
if ( results ) {
|
914
|
+
results.push.apply( results, array );
|
915
|
+
return results;
|
916
|
+
}
|
917
|
+
|
918
|
+
return array;
|
919
|
+
};
|
920
|
+
|
921
|
+
// Perform a simple check to determine if the browser is capable of
|
922
|
+
// converting a NodeList to an array using builtin methods.
|
923
|
+
// Also verifies that the returned array holds DOM nodes
|
924
|
+
// (which is not the case in the Blackberry browser)
|
925
|
+
try {
|
926
|
+
Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
|
927
|
+
|
928
|
+
// Provide a fallback method if it does not work
|
929
|
+
} catch( e ) {
|
930
|
+
makeArray = function( array, results ) {
|
931
|
+
var i = 0,
|
932
|
+
ret = results || [];
|
933
|
+
|
934
|
+
if ( toString.call(array) === "[object Array]" ) {
|
935
|
+
Array.prototype.push.apply( ret, array );
|
936
|
+
|
937
|
+
} else {
|
938
|
+
if ( typeof array.length === "number" ) {
|
939
|
+
for ( var l = array.length; i < l; i++ ) {
|
940
|
+
ret.push( array[i] );
|
941
|
+
}
|
942
|
+
|
943
|
+
} else {
|
944
|
+
for ( ; array[i]; i++ ) {
|
945
|
+
ret.push( array[i] );
|
946
|
+
}
|
947
|
+
}
|
948
|
+
}
|
949
|
+
|
950
|
+
return ret;
|
951
|
+
};
|
952
|
+
}
|
953
|
+
|
954
|
+
var sortOrder, siblingCheck;
|
955
|
+
|
956
|
+
if ( document.documentElement.compareDocumentPosition ) {
|
957
|
+
sortOrder = function( a, b ) {
|
958
|
+
if ( a === b ) {
|
959
|
+
hasDuplicate = true;
|
960
|
+
return 0;
|
961
|
+
}
|
962
|
+
|
963
|
+
if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
|
964
|
+
return a.compareDocumentPosition ? -1 : 1;
|
965
|
+
}
|
966
|
+
|
967
|
+
return a.compareDocumentPosition(b) & 4 ? -1 : 1;
|
968
|
+
};
|
969
|
+
|
970
|
+
} else {
|
971
|
+
sortOrder = function( a, b ) {
|
972
|
+
// The nodes are identical, we can exit early
|
973
|
+
if ( a === b ) {
|
974
|
+
hasDuplicate = true;
|
975
|
+
return 0;
|
976
|
+
|
977
|
+
// Fallback to using sourceIndex (in IE) if it's available on both nodes
|
978
|
+
} else if ( a.sourceIndex && b.sourceIndex ) {
|
979
|
+
return a.sourceIndex - b.sourceIndex;
|
980
|
+
}
|
981
|
+
|
982
|
+
var al, bl,
|
983
|
+
ap = [],
|
984
|
+
bp = [],
|
985
|
+
aup = a.parentNode,
|
986
|
+
bup = b.parentNode,
|
987
|
+
cur = aup;
|
988
|
+
|
989
|
+
// If the nodes are siblings (or identical) we can do a quick check
|
990
|
+
if ( aup === bup ) {
|
991
|
+
return siblingCheck( a, b );
|
992
|
+
|
993
|
+
// If no parents were found then the nodes are disconnected
|
994
|
+
} else if ( !aup ) {
|
995
|
+
return -1;
|
996
|
+
|
997
|
+
} else if ( !bup ) {
|
998
|
+
return 1;
|
999
|
+
}
|
1000
|
+
|
1001
|
+
// Otherwise they're somewhere else in the tree so we need
|
1002
|
+
// to build up a full list of the parentNodes for comparison
|
1003
|
+
while ( cur ) {
|
1004
|
+
ap.unshift( cur );
|
1005
|
+
cur = cur.parentNode;
|
1006
|
+
}
|
1007
|
+
|
1008
|
+
cur = bup;
|
1009
|
+
|
1010
|
+
while ( cur ) {
|
1011
|
+
bp.unshift( cur );
|
1012
|
+
cur = cur.parentNode;
|
1013
|
+
}
|
1014
|
+
|
1015
|
+
al = ap.length;
|
1016
|
+
bl = bp.length;
|
1017
|
+
|
1018
|
+
// Start walking down the tree looking for a discrepancy
|
1019
|
+
for ( var i = 0; i < al && i < bl; i++ ) {
|
1020
|
+
if ( ap[i] !== bp[i] ) {
|
1021
|
+
return siblingCheck( ap[i], bp[i] );
|
1022
|
+
}
|
1023
|
+
}
|
1024
|
+
|
1025
|
+
// We ended someplace up the tree so do a sibling check
|
1026
|
+
return i === al ?
|
1027
|
+
siblingCheck( a, bp[i], -1 ) :
|
1028
|
+
siblingCheck( ap[i], b, 1 );
|
1029
|
+
};
|
1030
|
+
|
1031
|
+
siblingCheck = function( a, b, ret ) {
|
1032
|
+
if ( a === b ) {
|
1033
|
+
return ret;
|
1034
|
+
}
|
1035
|
+
|
1036
|
+
var cur = a.nextSibling;
|
1037
|
+
|
1038
|
+
while ( cur ) {
|
1039
|
+
if ( cur === b ) {
|
1040
|
+
return -1;
|
1041
|
+
}
|
1042
|
+
|
1043
|
+
cur = cur.nextSibling;
|
1044
|
+
}
|
1045
|
+
|
1046
|
+
return 1;
|
1047
|
+
};
|
1048
|
+
}
|
1049
|
+
|
1050
|
+
// Check to see if the browser returns elements by name when
|
1051
|
+
// querying by getElementById (and provide a workaround)
|
1052
|
+
(function(){
|
1053
|
+
// We're going to inject a fake input element with a specified name
|
1054
|
+
var form = document.createElement("div"),
|
1055
|
+
id = "script" + (new Date()).getTime(),
|
1056
|
+
root = document.documentElement;
|
1057
|
+
|
1058
|
+
form.innerHTML = "<a name='" + id + "'/>";
|
1059
|
+
|
1060
|
+
// Inject it into the root element, check its status, and remove it quickly
|
1061
|
+
root.insertBefore( form, root.firstChild );
|
1062
|
+
|
1063
|
+
// The workaround has to do additional checks after a getElementById
|
1064
|
+
// Which slows things down for other browsers (hence the branching)
|
1065
|
+
if ( document.getElementById( id ) ) {
|
1066
|
+
Expr.find.ID = function( match, context, isXML ) {
|
1067
|
+
if ( typeof context.getElementById !== "undefined" && !isXML ) {
|
1068
|
+
var m = context.getElementById(match[1]);
|
1069
|
+
|
1070
|
+
return m ?
|
1071
|
+
m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ?
|
1072
|
+
[m] :
|
1073
|
+
undefined :
|
1074
|
+
[];
|
1075
|
+
}
|
1076
|
+
};
|
1077
|
+
|
1078
|
+
Expr.filter.ID = function( elem, match ) {
|
1079
|
+
var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
|
1080
|
+
|
1081
|
+
return elem.nodeType === 1 && node && node.nodeValue === match;
|
1082
|
+
};
|
1083
|
+
}
|
1084
|
+
|
1085
|
+
root.removeChild( form );
|
1086
|
+
|
1087
|
+
// release memory in IE
|
1088
|
+
root = form = null;
|
1089
|
+
})();
|
1090
|
+
|
1091
|
+
(function(){
|
1092
|
+
// Check to see if the browser returns only elements
|
1093
|
+
// when doing getElementsByTagName("*")
|
1094
|
+
|
1095
|
+
// Create a fake element
|
1096
|
+
var div = document.createElement("div");
|
1097
|
+
div.appendChild( document.createComment("") );
|
1098
|
+
|
1099
|
+
// Make sure no comments are found
|
1100
|
+
if ( div.getElementsByTagName("*").length > 0 ) {
|
1101
|
+
Expr.find.TAG = function( match, context ) {
|
1102
|
+
var results = context.getElementsByTagName( match[1] );
|
1103
|
+
|
1104
|
+
// Filter out possible comments
|
1105
|
+
if ( match[1] === "*" ) {
|
1106
|
+
var tmp = [];
|
1107
|
+
|
1108
|
+
for ( var i = 0; results[i]; i++ ) {
|
1109
|
+
if ( results[i].nodeType === 1 ) {
|
1110
|
+
tmp.push( results[i] );
|
1111
|
+
}
|
1112
|
+
}
|
1113
|
+
|
1114
|
+
results = tmp;
|
1115
|
+
}
|
1116
|
+
|
1117
|
+
return results;
|
1118
|
+
};
|
1119
|
+
}
|
1120
|
+
|
1121
|
+
// Check to see if an attribute returns normalized href attributes
|
1122
|
+
div.innerHTML = "<a href='#'></a>";
|
1123
|
+
|
1124
|
+
if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
|
1125
|
+
div.firstChild.getAttribute("href") !== "#" ) {
|
1126
|
+
|
1127
|
+
Expr.attrHandle.href = function( elem ) {
|
1128
|
+
return elem.getAttribute( "href", 2 );
|
1129
|
+
};
|
1130
|
+
}
|
1131
|
+
|
1132
|
+
// release memory in IE
|
1133
|
+
div = null;
|
1134
|
+
})();
|
1135
|
+
|
1136
|
+
if ( document.querySelectorAll ) {
|
1137
|
+
(function(){
|
1138
|
+
var oldSizzle = Sizzle,
|
1139
|
+
div = document.createElement("div"),
|
1140
|
+
id = "__sizzle__";
|
1141
|
+
|
1142
|
+
div.innerHTML = "<p class='TEST'></p>";
|
1143
|
+
|
1144
|
+
// Safari can't handle uppercase or unicode characters when
|
1145
|
+
// in quirks mode.
|
1146
|
+
if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
|
1147
|
+
return;
|
1148
|
+
}
|
1149
|
+
|
1150
|
+
Sizzle = function( query, context, extra, seed ) {
|
1151
|
+
context = context || document;
|
1152
|
+
|
1153
|
+
// Only use querySelectorAll on non-XML documents
|
1154
|
+
// (ID selectors don't work in non-HTML documents)
|
1155
|
+
if ( !seed && !Sizzle.isXML(context) ) {
|
1156
|
+
// See if we find a selector to speed up
|
1157
|
+
var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
|
1158
|
+
|
1159
|
+
if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
|
1160
|
+
// Speed-up: Sizzle("TAG")
|
1161
|
+
if ( match[1] ) {
|
1162
|
+
return makeArray( context.getElementsByTagName( query ), extra );
|
1163
|
+
|
1164
|
+
// Speed-up: Sizzle(".CLASS")
|
1165
|
+
} else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
|
1166
|
+
return makeArray( context.getElementsByClassName( match[2] ), extra );
|
1167
|
+
}
|
1168
|
+
}
|
1169
|
+
|
1170
|
+
if ( context.nodeType === 9 ) {
|
1171
|
+
// Speed-up: Sizzle("body")
|
1172
|
+
// The body element only exists once, optimize finding it
|
1173
|
+
if ( query === "body" && context.body ) {
|
1174
|
+
return makeArray( [ context.body ], extra );
|
1175
|
+
|
1176
|
+
// Speed-up: Sizzle("#ID")
|
1177
|
+
} else if ( match && match[3] ) {
|
1178
|
+
var elem = context.getElementById( match[3] );
|
1179
|
+
|
1180
|
+
// Check parentNode to catch when Blackberry 4.6 returns
|
1181
|
+
// nodes that are no longer in the document #6963
|
1182
|
+
if ( elem && elem.parentNode ) {
|
1183
|
+
// Handle the case where IE and Opera return items
|
1184
|
+
// by name instead of ID
|
1185
|
+
if ( elem.id === match[3] ) {
|
1186
|
+
return makeArray( [ elem ], extra );
|
1187
|
+
}
|
1188
|
+
|
1189
|
+
} else {
|
1190
|
+
return makeArray( [], extra );
|
1191
|
+
}
|
1192
|
+
}
|
1193
|
+
|
1194
|
+
try {
|
1195
|
+
return makeArray( context.querySelectorAll(query), extra );
|
1196
|
+
} catch(qsaError) {}
|
1197
|
+
|
1198
|
+
// qSA works strangely on Element-rooted queries
|
1199
|
+
// We can work around this by specifying an extra ID on the root
|
1200
|
+
// and working up from there (Thanks to Andrew Dupont for the technique)
|
1201
|
+
// IE 8 doesn't work on object elements
|
1202
|
+
} else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
|
1203
|
+
var oldContext = context,
|
1204
|
+
old = context.getAttribute( "id" ),
|
1205
|
+
nid = old || id,
|
1206
|
+
hasParent = context.parentNode,
|
1207
|
+
relativeHierarchySelector = /^\s*[+~]/.test( query );
|
1208
|
+
|
1209
|
+
if ( !old ) {
|
1210
|
+
context.setAttribute( "id", nid );
|
1211
|
+
} else {
|
1212
|
+
nid = nid.replace( /'/g, "\\$&" );
|
1213
|
+
}
|
1214
|
+
if ( relativeHierarchySelector && hasParent ) {
|
1215
|
+
context = context.parentNode;
|
1216
|
+
}
|
1217
|
+
|
1218
|
+
try {
|
1219
|
+
if ( !relativeHierarchySelector || hasParent ) {
|
1220
|
+
return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra );
|
1221
|
+
}
|
1222
|
+
|
1223
|
+
} catch(pseudoError) {
|
1224
|
+
} finally {
|
1225
|
+
if ( !old ) {
|
1226
|
+
oldContext.removeAttribute( "id" );
|
1227
|
+
}
|
1228
|
+
}
|
1229
|
+
}
|
1230
|
+
}
|
1231
|
+
|
1232
|
+
return oldSizzle(query, context, extra, seed);
|
1233
|
+
};
|
1234
|
+
|
1235
|
+
for ( var prop in oldSizzle ) {
|
1236
|
+
Sizzle[ prop ] = oldSizzle[ prop ];
|
1237
|
+
}
|
1238
|
+
|
1239
|
+
// release memory in IE
|
1240
|
+
div = null;
|
1241
|
+
})();
|
1242
|
+
}
|
1243
|
+
|
1244
|
+
(function(){
|
1245
|
+
var html = document.documentElement,
|
1246
|
+
matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector;
|
1247
|
+
|
1248
|
+
if ( matches ) {
|
1249
|
+
// Check to see if it's possible to do matchesSelector
|
1250
|
+
// on a disconnected node (IE 9 fails this)
|
1251
|
+
var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ),
|
1252
|
+
pseudoWorks = false;
|
1253
|
+
|
1254
|
+
try {
|
1255
|
+
// This should fail with an exception
|
1256
|
+
// Gecko does not error, returns false instead
|
1257
|
+
matches.call( document.documentElement, "[test!='']:sizzle" );
|
1258
|
+
|
1259
|
+
} catch( pseudoError ) {
|
1260
|
+
pseudoWorks = true;
|
1261
|
+
}
|
1262
|
+
|
1263
|
+
Sizzle.matchesSelector = function( node, expr ) {
|
1264
|
+
// Make sure that attribute selectors are quoted
|
1265
|
+
expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
|
1266
|
+
|
1267
|
+
if ( !Sizzle.isXML( node ) ) {
|
1268
|
+
try {
|
1269
|
+
if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
|
1270
|
+
var ret = matches.call( node, expr );
|
1271
|
+
|
1272
|
+
// IE 9's matchesSelector returns false on disconnected nodes
|
1273
|
+
if ( ret || !disconnectedMatch ||
|
1274
|
+
// As well, disconnected nodes are said to be in a document
|
1275
|
+
// fragment in IE 9, so check for that
|
1276
|
+
node.document && node.document.nodeType !== 11 ) {
|
1277
|
+
return ret;
|
1278
|
+
}
|
1279
|
+
}
|
1280
|
+
} catch(e) {}
|
1281
|
+
}
|
1282
|
+
|
1283
|
+
return Sizzle(expr, null, null, [node]).length > 0;
|
1284
|
+
};
|
1285
|
+
}
|
1286
|
+
})();
|
1287
|
+
|
1288
|
+
(function(){
|
1289
|
+
var div = document.createElement("div");
|
1290
|
+
|
1291
|
+
div.innerHTML = "<div class='test e'></div><div class='test'></div>";
|
1292
|
+
|
1293
|
+
// Opera can't find a second classname (in 9.6)
|
1294
|
+
// Also, make sure that getElementsByClassName actually exists
|
1295
|
+
if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
|
1296
|
+
return;
|
1297
|
+
}
|
1298
|
+
|
1299
|
+
// Safari caches class attributes, doesn't catch changes (in 3.2)
|
1300
|
+
div.lastChild.className = "e";
|
1301
|
+
|
1302
|
+
if ( div.getElementsByClassName("e").length === 1 ) {
|
1303
|
+
return;
|
1304
|
+
}
|
1305
|
+
|
1306
|
+
Expr.order.splice(1, 0, "CLASS");
|
1307
|
+
Expr.find.CLASS = function( match, context, isXML ) {
|
1308
|
+
if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
|
1309
|
+
return context.getElementsByClassName(match[1]);
|
1310
|
+
}
|
1311
|
+
};
|
1312
|
+
|
1313
|
+
// release memory in IE
|
1314
|
+
div = null;
|
1315
|
+
})();
|
1316
|
+
|
1317
|
+
function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
|
1318
|
+
for ( var i = 0, l = checkSet.length; i < l; i++ ) {
|
1319
|
+
var elem = checkSet[i];
|
1320
|
+
|
1321
|
+
if ( elem ) {
|
1322
|
+
var match = false;
|
1323
|
+
|
1324
|
+
elem = elem[dir];
|
1325
|
+
|
1326
|
+
while ( elem ) {
|
1327
|
+
if ( elem[ expando ] === doneName ) {
|
1328
|
+
match = checkSet[elem.sizset];
|
1329
|
+
break;
|
1330
|
+
}
|
1331
|
+
|
1332
|
+
if ( elem.nodeType === 1 && !isXML ){
|
1333
|
+
elem[ expando ] = doneName;
|
1334
|
+
elem.sizset = i;
|
1335
|
+
}
|
1336
|
+
|
1337
|
+
if ( elem.nodeName.toLowerCase() === cur ) {
|
1338
|
+
match = elem;
|
1339
|
+
break;
|
1340
|
+
}
|
1341
|
+
|
1342
|
+
elem = elem[dir];
|
1343
|
+
}
|
1344
|
+
|
1345
|
+
checkSet[i] = match;
|
1346
|
+
}
|
1347
|
+
}
|
1348
|
+
}
|
1349
|
+
|
1350
|
+
function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
|
1351
|
+
for ( var i = 0, l = checkSet.length; i < l; i++ ) {
|
1352
|
+
var elem = checkSet[i];
|
1353
|
+
|
1354
|
+
if ( elem ) {
|
1355
|
+
var match = false;
|
1356
|
+
|
1357
|
+
elem = elem[dir];
|
1358
|
+
|
1359
|
+
while ( elem ) {
|
1360
|
+
if ( elem[ expando ] === doneName ) {
|
1361
|
+
match = checkSet[elem.sizset];
|
1362
|
+
break;
|
1363
|
+
}
|
1364
|
+
|
1365
|
+
if ( elem.nodeType === 1 ) {
|
1366
|
+
if ( !isXML ) {
|
1367
|
+
elem[ expando ] = doneName;
|
1368
|
+
elem.sizset = i;
|
1369
|
+
}
|
1370
|
+
|
1371
|
+
if ( typeof cur !== "string" ) {
|
1372
|
+
if ( elem === cur ) {
|
1373
|
+
match = true;
|
1374
|
+
break;
|
1375
|
+
}
|
1376
|
+
|
1377
|
+
} else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
|
1378
|
+
match = elem;
|
1379
|
+
break;
|
1380
|
+
}
|
1381
|
+
}
|
1382
|
+
|
1383
|
+
elem = elem[dir];
|
1384
|
+
}
|
1385
|
+
|
1386
|
+
checkSet[i] = match;
|
1387
|
+
}
|
1388
|
+
}
|
1389
|
+
}
|
1390
|
+
|
1391
|
+
if ( document.documentElement.contains ) {
|
1392
|
+
Sizzle.contains = function( a, b ) {
|
1393
|
+
return a !== b && (a.contains ? a.contains(b) : true);
|
1394
|
+
};
|
1395
|
+
|
1396
|
+
} else if ( document.documentElement.compareDocumentPosition ) {
|
1397
|
+
Sizzle.contains = function( a, b ) {
|
1398
|
+
return !!(a.compareDocumentPosition(b) & 16);
|
1399
|
+
};
|
1400
|
+
|
1401
|
+
} else {
|
1402
|
+
Sizzle.contains = function() {
|
1403
|
+
return false;
|
1404
|
+
};
|
1405
|
+
}
|
1406
|
+
|
1407
|
+
Sizzle.isXML = function( elem ) {
|
1408
|
+
// documentElement is verified for cases where it doesn't yet exist
|
1409
|
+
// (such as loading iframes in IE - #4833)
|
1410
|
+
var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
|
1411
|
+
|
1412
|
+
return documentElement ? documentElement.nodeName !== "HTML" : false;
|
1413
|
+
};
|
1414
|
+
|
1415
|
+
var posProcess = function( selector, context, seed ) {
|
1416
|
+
var match,
|
1417
|
+
tmpSet = [],
|
1418
|
+
later = "",
|
1419
|
+
root = context.nodeType ? [context] : context;
|
1420
|
+
|
1421
|
+
// Position selectors must be done after the filter
|
1422
|
+
// And so must :not(positional) so we move all PSEUDOs to the end
|
1423
|
+
while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
|
1424
|
+
later += match[0];
|
1425
|
+
selector = selector.replace( Expr.match.PSEUDO, "" );
|
1426
|
+
}
|
1427
|
+
|
1428
|
+
selector = Expr.relative[selector] ? selector + "*" : selector;
|
1429
|
+
|
1430
|
+
for ( var i = 0, l = root.length; i < l; i++ ) {
|
1431
|
+
Sizzle( selector, root[i], tmpSet, seed );
|
1432
|
+
}
|
1433
|
+
|
1434
|
+
return Sizzle.filter( later, tmpSet );
|
1435
|
+
};
|
1436
|
+
|
1437
|
+
// EXPOSE
|
1438
|
+
|
1439
|
+
window.Sizzle = Sizzle;
|
1440
|
+
|
1441
|
+
})();
|
1442
|
+
|