Skip to content

Commit 736dcbf

Browse files
moosMoos
authored and
Moos
committed
fixed jshint errors
1 parent ee461c9 commit 736dcbf

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

index.js

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,16 @@ function parse(selector, options){
7878
data, firstChar, name;
7979

8080
function getName(){
81-
var sub = escaped_name = selector.match(re_name)[0];
81+
var sub = selector.match(re_name)[0];
82+
escaped_name = sub;
8283
selector = selector.substr(sub.length);
8384
return unescapeCSS(sub);
8485
}
8586

8687
while(selector !== ""){
8788
if(re_name.test(selector)){
8889
if(sawWS){
89-
selectorette.push(' ');
90+
selectorette.push(" ");
9091
tokens.push({type: "descendant"});
9192
sawWS = false;
9293
}
@@ -107,12 +108,14 @@ function parse(selector, options){
107108
selector = selector.substr(1);
108109

109110
if(firstChar in simpleSelectors){
110-
sawWS && selectorette.push(' ');
111+
if (sawWS){
112+
selectorette.push(" ");
113+
}
111114
selectorette.push(firstChar);
112115
tokens.push({type: simpleSelectors[firstChar]});
113116

114117
if(re_ws.test(selector)){
115-
selectorette.push(' ');
118+
selectorette.push(" ");
116119
}
117120
selector = selector.trimLeft();
118121
sawWS = false;
@@ -125,14 +128,14 @@ function parse(selector, options){
125128
subselects.push(tokens);
126129
tokens = [];
127130

128-
selectors.push(selectorette.join(''));
131+
selectors.push(selectorette.join(""));
129132
selectorette = [];
130133

131134
selector = selector.trimLeft();
132135
sawWS = false;
133136
continue;
134137
} else if(sawWS){
135-
selectorette.push(' ');
138+
selectorette.push(" ");
136139
tokens.push({type: "descendant"});
137140
sawWS = false;
138141
}
@@ -177,17 +180,17 @@ function parse(selector, options){
177180
});
178181

179182
// reconstruct selector from data
180-
data[4] = data[4] !== undefined ? data[4] + '=' : '';
183+
data[4] = data[4] !== undefined ? data[4] + "=" : "";
181184
data[5] = data[5] || "";
182185
data[6] = data[6] || "";
183186

184-
selectorette.push( // "[ href *= 'google' i]"
185-
firstChar // [
186-
+ data[1] + data[2] + data[3] // \s href \s
187-
+ data[4] + data[5] // *= \s
188-
+ data[6] + value + data[6] // \'(google || undefined || '')\'
189-
+ data[9] + (data[10] || '') // \s i
190-
+ ']'); // ]
187+
selectorette.push( // "[ href *= 'google' i]"
188+
firstChar + // [
189+
data[1] + data[2] + data[3] + // \s href \s
190+
data[4] + data[5] + // *= \s
191+
data[6] + value + data[6] + // \'(google || undefined || '')\'
192+
data[9] + (data[10] || "") + // \s i
193+
"]"); // ]
191194

192195
} else if(firstChar === ":"){
193196
//if(selector.charAt(0) === ":"){} //TODO pseudo-element
@@ -201,7 +204,7 @@ function parse(selector, options){
201204
}
202205

203206
tokens.push({type: "pseudo", name: name, data: data});
204-
selectorette.push(firstChar + escaped_name + (data ? '(' + data + ')' : ''));
207+
selectorette.push(firstChar + escaped_name + (data ? "(" + data + ")" : ""));
205208
} else {
206209
//otherwise, the parser needs to throw or it would enter an infinite loop
207210
throw new SyntaxError("Unmatched selector: " + firstChar + selector);
@@ -213,8 +216,10 @@ function parse(selector, options){
213216
throw new SyntaxError("empty sub-selector");
214217
}
215218

216-
selectors.push(selectorette.join(''));
217-
options && (options.selectors = selectors);
219+
selectors.push(selectorette.join(""));
220+
if (options) {
221+
options.selectors = selectors;
222+
}
218223

219224
subselects.push(tokens);
220225

0 commit comments

Comments
 (0)