-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestJq.html
77 lines (60 loc) · 2.28 KB
/
testJq.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div></div>
<!--<div id="test">-->
<!--我是测试啊-->
<!--<div id="must">333 </div>-->
<!--</div>-->
<!--<script src="js/test/testJq.js"></script>-->
<script>
;
(function () {
var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g;
var Sizzle = function (selector) {
if(!selector || typeof selector!=="string"){
return false;
}
var m = '',
sofar = selector,
extra,
parts = [];
do{
chunker.exec('');
m = chunker.exec(sofar);
console.log(m);
if(m){
sofar = m[3];
parts.push(m[1]);
if(m[2]){
extra = m[3];
break;
}
}
}while(m)
console.log(parts);
console.log(extra);
};
var Expr = Sizzle.selectors = {
order: ["ID", "NAME", "TAG"],
match: {
ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,
TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,
POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
}
}
window['Sizzle'] = Sizzle;
})();
Sizzle("div button:first,div p:first,p span:first");
</script>
</body>
</html>