Skip to content

Commit 642079e

Browse files
committed
consistently use tabs
1 parent 1ddb673 commit 642079e

File tree

1 file changed

+100
-100
lines changed

1 file changed

+100
-100
lines changed

index.js

+100-100
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,21 @@ var attribSelectors = {
3535

3636
//pseudos, whose data-property is parsed as well
3737
var unpackPseudos = {
38-
__proto__: null,
39-
"has": true,
40-
"not": true,
41-
"matches": true
38+
__proto__: null,
39+
"has": true,
40+
"not": true,
41+
"matches": true
4242
};
4343

4444
var stripQuotesFromPseudos = {
45-
__proto__: null,
46-
"contains": true
45+
__proto__: null,
46+
"contains": true
4747
};
4848

4949
var quotes = {
50-
__proto__: null,
51-
"\"": true,
52-
"'": true
50+
__proto__: null,
51+
"\"": true,
52+
"'": true
5353
};
5454

5555
//unescape function taken from https://github.com/jquery/sizzle/blob/master/src/sizzle.js#L139
@@ -72,71 +72,71 @@ function unescapeCSS(str){
7272
}
7373

7474
function isWhitespace(c){
75-
return c === " " || c === "\n" || c === "\t" || c === "\f" || c === "\r";
75+
return c === " " || c === "\n" || c === "\t" || c === "\f" || c === "\r";
7676
}
7777

7878
function parse(selector, options){
7979
var subselects = [];
8080

81-
selector = parseSelector(subselects, selector + "", options);
81+
selector = parseSelector(subselects, selector + "", options);
8282

83-
if(selector !== ""){
84-
throw new SyntaxError("Unmatched selector: " + selector);
85-
}
83+
if(selector !== ""){
84+
throw new SyntaxError("Unmatched selector: " + selector);
85+
}
8686

87-
return subselects;
87+
return subselects;
8888
}
8989

9090
function parseSelector(subselects, selector, options){
91-
var tokens = [],
92-
sawWS = false,
93-
data, firstChar, name, quot;
91+
var tokens = [],
92+
sawWS = false,
93+
data, firstChar, name, quot;
9494

9595
function getName(){
9696
var sub = selector.match(re_name)[0];
9797
selector = selector.substr(sub.length);
9898
return unescapeCSS(sub);
9999
}
100100

101-
function stripWhitespace(start){
102-
while(isWhitespace(selector.charAt(start))) start++;
103-
selector = selector.substr(start);
104-
}
101+
function stripWhitespace(start){
102+
while(isWhitespace(selector.charAt(start))) start++;
103+
selector = selector.substr(start);
104+
}
105105

106-
stripWhitespace(0);
106+
stripWhitespace(0);
107107

108108
while(selector !== ""){
109-
firstChar = selector.charAt(0);
109+
firstChar = selector.charAt(0);
110110

111-
if(isWhitespace(firstChar)){
111+
if(isWhitespace(firstChar)){
112112
sawWS = true;
113-
stripWhitespace(1);
113+
stripWhitespace(1);
114114
} else if(firstChar in simpleSelectors){
115-
tokens.push({type: simpleSelectors[firstChar]});
116-
sawWS = false;
117-
118-
stripWhitespace(1);
119-
} else if(firstChar === ","){
120-
if(tokens.length === 0){
121-
throw new SyntaxError("empty sub-selector");
122-
}
123-
subselects.push(tokens);
124-
tokens = [];
125-
sawWS = false;
126-
stripWhitespace(1);
127-
} else {
115+
tokens.push({type: simpleSelectors[firstChar]});
116+
sawWS = false;
117+
118+
stripWhitespace(1);
119+
} else if(firstChar === ","){
120+
if(tokens.length === 0){
121+
throw new SyntaxError("empty sub-selector");
122+
}
123+
subselects.push(tokens);
124+
tokens = [];
125+
sawWS = false;
126+
stripWhitespace(1);
127+
} else {
128128
if(sawWS){
129-
if(tokens.length > 0){
130-
tokens.push({type: "descendant"});
131-
}
129+
if(tokens.length > 0){
130+
tokens.push({type: "descendant"});
131+
}
132132
sawWS = false;
133133
}
134134

135-
if(firstChar === "*"){
136-
selector = selector.substr(1);
135+
if(firstChar === "*"){
136+
selector = selector.substr(1);
137137
tokens.push({type: "universal"});
138138
} else if(firstChar in attribSelectors){
139-
selector = selector.substr(1);
139+
selector = selector.substr(1);
140140
tokens.push({
141141
type: "attribute",
142142
name: attribSelectors[firstChar][0],
@@ -145,7 +145,7 @@ function parseSelector(subselects, selector, options){
145145
ignoreCase: false
146146
});
147147
} else if(firstChar === "["){
148-
selector = selector.substr(1);
148+
selector = selector.substr(1);
149149
data = selector.match(re_attr);
150150
if(!data){
151151
throw new SyntaxError("Malformed attribute selector: " + selector);
@@ -174,89 +174,89 @@ function parseSelector(subselects, selector, options){
174174
} else if(firstChar === ":"){
175175
//if(selector.charAt(1) === ":"){} //TODO pseudo-element
176176

177-
selector = selector.substr(1);
177+
selector = selector.substr(1);
178178

179179
name = getName().toLowerCase();
180180
data = null;
181181

182182
if(selector.charAt(0) === "("){
183-
if(name in unpackPseudos){
184-
quot = selector.charAt(1);
185-
var quoted = quot in quotes;
183+
if(name in unpackPseudos){
184+
quot = selector.charAt(1);
185+
var quoted = quot in quotes;
186186

187-
selector = selector.substr(quoted + 1);
187+
selector = selector.substr(quoted + 1);
188188

189-
data = [];
190-
selector = parseSelector(data, selector, options);
189+
data = [];
190+
selector = parseSelector(data, selector, options);
191191

192-
if(quoted){
193-
if(selector.charAt(0) !== quot){
194-
throw new SyntaxError("unmatched quotes in :" + name);
195-
} else {
196-
selector = selector.substr(1);
197-
}
198-
}
192+
if(quoted){
193+
if(selector.charAt(0) !== quot){
194+
throw new SyntaxError("unmatched quotes in :" + name);
195+
} else {
196+
selector = selector.substr(1);
197+
}
198+
}
199199

200-
if(selector.charAt(0) !== ")"){
201-
throw new SyntaxError("missing closing parenthesis in :" + name + " " + selector);
202-
}
200+
if(selector.charAt(0) !== ")"){
201+
throw new SyntaxError("missing closing parenthesis in :" + name + " " + selector);
202+
}
203203

204-
selector = selector.substr(1);
205-
} else {
206-
var pos = 1, counter = 1;
204+
selector = selector.substr(1);
205+
} else {
206+
var pos = 1, counter = 1;
207207

208-
for(; counter > 0 && pos < selector.length; pos++){
209-
if(selector.charAt(pos) === "(") counter++;
210-
else if(selector.charAt(pos) === ")") counter--;
211-
}
208+
for(; counter > 0 && pos < selector.length; pos++){
209+
if(selector.charAt(pos) === "(") counter++;
210+
else if(selector.charAt(pos) === ")") counter--;
211+
}
212212

213-
if(counter){
214-
throw new SyntaxError("parenthesis not matched");
215-
}
213+
if(counter){
214+
throw new SyntaxError("parenthesis not matched");
215+
}
216216

217-
data = selector.substr(1, pos - 2);
218-
selector = selector.substr(pos);
217+
data = selector.substr(1, pos - 2);
218+
selector = selector.substr(pos);
219219

220-
if(name in stripQuotesFromPseudos){
221-
quot = data.charAt(0);
220+
if(name in stripQuotesFromPseudos){
221+
quot = data.charAt(0);
222222

223-
if(quot === data.slice(-1) && quot in quotes){
224-
data = data.slice(1, -1);
225-
}
223+
if(quot === data.slice(-1) && quot in quotes){
224+
data = data.slice(1, -1);
225+
}
226226

227-
data = unescapeCSS(data);
228-
}
229-
}
227+
data = unescapeCSS(data);
228+
}
229+
}
230230
}
231231

232232
tokens.push({type: "pseudo", name: name, data: data});
233233
} else if(re_name.test(selector)){
234-
name = getName();
235-
236-
if(!options || ("lowerCaseTags" in options ? options.lowerCaseTags : !options.xmlMode)){
237-
name = name.toLowerCase();
238-
}
239-
240-
tokens.push({type: "tag", name: name});
241-
} else {
242-
if(tokens.length && tokens[tokens.length - 1].type === "descendant"){
243-
tokens.pop();
244-
}
245-
addToken(subselects, tokens);
246-
return selector;
234+
name = getName();
235+
236+
if(!options || ("lowerCaseTags" in options ? options.lowerCaseTags : !options.xmlMode)){
237+
name = name.toLowerCase();
238+
}
239+
240+
tokens.push({type: "tag", name: name});
241+
} else {
242+
if(tokens.length && tokens[tokens.length - 1].type === "descendant"){
243+
tokens.pop();
244+
}
245+
addToken(subselects, tokens);
246+
return selector;
247247
}
248248
}
249249
}
250250

251-
addToken(subselects, tokens);
251+
addToken(subselects, tokens);
252252

253253
return selector;
254254
}
255255

256256
function addToken(subselects, tokens){
257-
if(subselects.length > 0 && tokens.length === 0){
258-
throw new SyntaxError("empty sub-selector");
259-
}
257+
if(subselects.length > 0 && tokens.length === 0){
258+
throw new SyntaxError("empty sub-selector");
259+
}
260260

261261
subselects.push(tokens);
262262
}

0 commit comments

Comments
 (0)