Skip to content

Commit 50c1388

Browse files
committed
Use === instead of ==.
1 parent 0a02516 commit 50c1388

11 files changed

+111
-111
lines changed

src/css/Combinator.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ function Combinator(text, line, col){
2323
//pretty simple
2424
if (/^\s+$/.test(text)){
2525
this.type = "descendant";
26-
} else if (text == ">"){
26+
} else if (text === ">"){
2727
this.type = "child";
28-
} else if (text == "+"){
28+
} else if (text === "+"){
2929
this.type = "adjacent-sibling";
30-
} else if (text == "~"){
30+
} else if (text === "~"){
3131
this.type = "sibling";
3232
}
3333

src/css/Parser.js

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ Parser.prototype = function(){
8787
this._skipCruft();
8888

8989
//try to read imports - may be more than one
90-
while (tokenStream.peek() == Tokens.IMPORT_SYM){
90+
while (tokenStream.peek() === Tokens.IMPORT_SYM){
9191
this._import();
9292
this._skipCruft();
9393
}
9494

9595
//try to read namespaces - may be more than one
96-
while (tokenStream.peek() == Tokens.NAMESPACE_SYM){
96+
while (tokenStream.peek() === Tokens.NAMESPACE_SYM){
9797
this._namespace();
9898
this._skipCruft();
9999
}
@@ -146,7 +146,7 @@ Parser.prototype = function(){
146146

147147
//skip braces
148148
count=0;
149-
while (tokenStream.advance([Tokens.LBRACE, Tokens.RBRACE]) == Tokens.LBRACE){
149+
while (tokenStream.advance([Tokens.LBRACE, Tokens.RBRACE]) === Tokens.LBRACE){
150150
count++; //keep track of nesting depth
151151
}
152152

@@ -204,7 +204,7 @@ Parser.prototype = function(){
204204
tt = tokenStream.peek();
205205
}
206206

207-
if (tt != Tokens.EOF){
207+
if (tt !== Tokens.EOF){
208208
this._unexpectedToken(tokenStream.token());
209209
}
210210

@@ -366,13 +366,13 @@ Parser.prototype = function(){
366366
});
367367

368368
while(true) {
369-
if (tokenStream.peek() == Tokens.PAGE_SYM){
369+
if (tokenStream.peek() === Tokens.PAGE_SYM){
370370
this._page();
371-
} else if (tokenStream.peek() == Tokens.FONT_FACE_SYM){
371+
} else if (tokenStream.peek() === Tokens.FONT_FACE_SYM){
372372
this._font_face();
373-
} else if (tokenStream.peek() == Tokens.VIEWPORT_SYM){
373+
} else if (tokenStream.peek() === Tokens.VIEWPORT_SYM){
374374
this._viewport();
375-
} else if (tokenStream.peek() == Tokens.DOCUMENT_SYM){
375+
} else if (tokenStream.peek() === Tokens.DOCUMENT_SYM){
376376
this._document();
377377
} else if (!this._ruleset()){
378378
break;
@@ -404,7 +404,7 @@ Parser.prototype = function(){
404404

405405
this._readWhitespace();
406406

407-
if (tokenStream.peek() == Tokens.IDENT || tokenStream.peek() == Tokens.LPAREN){
407+
if (tokenStream.peek() === Tokens.IDENT || tokenStream.peek() === Tokens.LPAREN){
408408
mediaList.push(this._media_query());
409409
}
410410

@@ -438,7 +438,7 @@ Parser.prototype = function(){
438438
ident = tokenStream.token().value.toLowerCase();
439439

440440
//since there's no custom tokens for these, need to manually check
441-
if (ident != "only" && ident != "not"){
441+
if (ident !== "only" && ident !== "not"){
442442
tokenStream.unget();
443443
ident = null;
444444
} else {
@@ -448,12 +448,12 @@ Parser.prototype = function(){
448448

449449
this._readWhitespace();
450450

451-
if (tokenStream.peek() == Tokens.IDENT){
451+
if (tokenStream.peek() === Tokens.IDENT){
452452
type = this._media_type();
453453
if (token === null){
454454
token = tokenStream.token();
455455
}
456-
} else if (tokenStream.peek() == Tokens.LPAREN){
456+
} else if (tokenStream.peek() === Tokens.LPAREN){
457457
if (token === null){
458458
token = tokenStream.LT(1);
459459
}
@@ -465,7 +465,7 @@ Parser.prototype = function(){
465465
} else {
466466
this._readWhitespace();
467467
while (tokenStream.match(Tokens.IDENT)){
468-
if (tokenStream.token().value.toLowerCase() != "and"){
468+
if (tokenStream.token().value.toLowerCase() !== "and"){
469469
this._unexpectedToken(tokenStream.token());
470470
}
471471

@@ -570,7 +570,7 @@ Parser.prototype = function(){
570570
}
571571

572572
//see if there's a colon upcoming
573-
if (tokenStream.peek() == Tokens.COLON){
573+
if (tokenStream.peek() === Tokens.COLON){
574574
pseudoPage = this._pseudo_page();
575575
}
576576

@@ -798,13 +798,13 @@ Parser.prototype = function(){
798798
});
799799

800800
while(true) {
801-
if (tokenStream.peek() == Tokens.PAGE_SYM){
801+
if (tokenStream.peek() === Tokens.PAGE_SYM){
802802
this._page();
803-
} else if (tokenStream.peek() == Tokens.FONT_FACE_SYM){
803+
} else if (tokenStream.peek() === Tokens.FONT_FACE_SYM){
804804
this._font_face();
805-
} else if (tokenStream.peek() == Tokens.VIEWPORT_SYM){
805+
} else if (tokenStream.peek() === Tokens.VIEWPORT_SYM){
806806
this._viewport();
807-
} else if (tokenStream.peek() == Tokens.MEDIA_SYM){
807+
} else if (tokenStream.peek() === Tokens.MEDIA_SYM){
808808
this._media();
809809
} else if (!this._ruleset()){
810810
break;
@@ -920,7 +920,7 @@ Parser.prototype = function(){
920920
col;
921921

922922
//check for star hack - throws error if not allowed
923-
if (tokenStream.peek() == Tokens.STAR && this.options.starHack){
923+
if (tokenStream.peek() === Tokens.STAR && this.options.starHack){
924924
tokenStream.get();
925925
token = tokenStream.token();
926926
hack = token.value;
@@ -933,7 +933,7 @@ Parser.prototype = function(){
933933
tokenValue = token.value;
934934

935935
//check for underscore hack - no error if not allowed because it's valid CSS syntax
936-
if (tokenValue.charAt(0) == "_" && this.options.underscoreHack){
936+
if (tokenValue.charAt(0) === "_" && this.options.underscoreHack){
937937
hack = "_";
938938
tokenValue = tokenValue.substring(1);
939939
}
@@ -979,7 +979,7 @@ Parser.prototype = function(){
979979

980980
//skip over everything until closing brace
981981
tt = tokenStream.advance([Tokens.RBRACE]);
982-
if (tt == Tokens.RBRACE){
982+
if (tt === Tokens.RBRACE){
983983
//if there's a right brace, the rule is finished so don't do anything
984984
} else {
985985
//otherwise, rethrow the error because it wasn't handled properly
@@ -1418,7 +1418,7 @@ Parser.prototype = function(){
14181418
pseudo = tokenStream.token().value;
14191419
line = tokenStream.token().startLine;
14201420
col = tokenStream.token().startCol - colons.length;
1421-
} else if (tokenStream.peek() == Tokens.FUNCTION){
1421+
} else if (tokenStream.peek() === Tokens.FUNCTION){
14221422
line = tokenStream.LT(1).startLine;
14231423
col = tokenStream.LT(1).startCol - colons.length;
14241424
pseudo = this._functional_pseudo();
@@ -1555,7 +1555,7 @@ Parser.prototype = function(){
15551555
}
15561556

15571557
//it's an element name
1558-
if (arg.type == "elementName"){
1558+
if (arg.type === "elementName"){
15591559
part = new SelectorPart(arg, [], arg.toString(), line, col);
15601560
} else {
15611561
part = new SelectorPart(null, [arg], arg.toString(), line, col);
@@ -1602,8 +1602,8 @@ Parser.prototype = function(){
16021602
* _property or *property as invalid properties.
16031603
*/
16041604
propertyName = property.toString();
1605-
if (this.options.starHack && property.hack == "*" ||
1606-
this.options.underscoreHack && property.hack == "_") {
1605+
if (this.options.starHack && property.hack === "*" ||
1606+
this.options.underscoreHack && property.hack === "_") {
16071607

16081608
propertyName = property.text;
16091609
}
@@ -1719,7 +1719,7 @@ Parser.prototype = function(){
17191719
}
17201720

17211721
//exception for IE filters
1722-
if (tokenStream.peek() == Tokens.IE_FUNCTION && this.options.ieFilters){
1722+
if (tokenStream.peek() === Tokens.IE_FUNCTION && this.options.ieFilters){
17231723

17241724
value = this._ie_function();
17251725
if (unary === null){
@@ -1771,7 +1771,7 @@ Parser.prototype = function(){
17711771
* This checks for alpha(opacity=0) style of IE
17721772
* functions. IE_FUNCTION only presents progid: style.
17731773
*/
1774-
if (tokenStream.LA(3) == Tokens.EQUALS && this.options.ieFilters){
1774+
if (tokenStream.LA(3) === Tokens.EQUALS && this.options.ieFilters){
17751775
value = this._ie_function();
17761776
} else {
17771777
value = this._function();
@@ -1819,15 +1819,15 @@ Parser.prototype = function(){
18191819
functionText += expr;
18201820

18211821
//START: Horrible hack in case it's an IE filter
1822-
if (this.options.ieFilters && tokenStream.peek() == Tokens.EQUALS){
1822+
if (this.options.ieFilters && tokenStream.peek() === Tokens.EQUALS){
18231823
do {
18241824

18251825
if (this._readWhitespace()){
18261826
functionText += tokenStream.token().value;
18271827
}
18281828

18291829
//might be second time in the loop
1830-
if (tokenStream.LA(0) == Tokens.COMMA){
1830+
if (tokenStream.LA(0) === Tokens.COMMA){
18311831
functionText += tokenStream.token().value;
18321832
}
18331833

@@ -1839,7 +1839,7 @@ Parser.prototype = function(){
18391839

18401840
//functionText += this._term();
18411841
lt = tokenStream.peek();
1842-
while(lt != Tokens.COMMA && lt != Tokens.S && lt != Tokens.RPAREN){
1842+
while(lt !== Tokens.COMMA && lt !== Tokens.S && lt !== Tokens.RPAREN){
18431843
tokenStream.get();
18441844
functionText += tokenStream.token().value;
18451845
lt = tokenStream.peek();
@@ -1881,7 +1881,7 @@ Parser.prototype = function(){
18811881
}
18821882

18831883
//might be second time in the loop
1884-
if (tokenStream.LA(0) == Tokens.COMMA){
1884+
if (tokenStream.LA(0) === Tokens.COMMA){
18851885
functionText += tokenStream.token().value;
18861886
}
18871887

@@ -1893,7 +1893,7 @@ Parser.prototype = function(){
18931893

18941894
//functionText += this._term();
18951895
lt = tokenStream.peek();
1896-
while(lt != Tokens.COMMA && lt != Tokens.S && lt != Tokens.RPAREN){
1896+
while(lt !== Tokens.COMMA && lt !== Tokens.S && lt !== Tokens.RPAREN){
18971897
tokenStream.get();
18981898
functionText += tokenStream.token().value;
18991899
lt = tokenStream.peek();
@@ -1979,7 +1979,7 @@ Parser.prototype = function(){
19791979
tt = tokenStream.peek();
19801980

19811981
//check for key
1982-
while(tt == Tokens.IDENT || tt == Tokens.PERCENTAGE) {
1982+
while(tt === Tokens.IDENT || tt === Tokens.PERCENTAGE) {
19831983
this._keyframe_rule();
19841984
this._readWhitespace();
19851985
tt = tokenStream.peek();
@@ -2186,10 +2186,10 @@ Parser.prototype = function(){
21862186

21872187
//see if there's another declaration
21882188
tt = tokenStream.advance([Tokens.SEMICOLON, Tokens.RBRACE]);
2189-
if (tt == Tokens.SEMICOLON){
2189+
if (tt === Tokens.SEMICOLON){
21902190
//if there's a semicolon, then there might be another declaration
21912191
this._readDeclarations(false, readMargins);
2192-
} else if (tt != Tokens.RBRACE){
2192+
} else if (tt !== Tokens.RBRACE){
21932193
//if there's a right brace, the rule is finished so don't do anything
21942194
//otherwise, rethrow the error because it wasn't handled properly
21952195
throw ex;
@@ -2243,7 +2243,7 @@ Parser.prototype = function(){
22432243
* @private
22442244
*/
22452245
_verifyEnd: function(){
2246-
if (this._tokenStream.LA(1) != Tokens.EOF){
2246+
if (this._tokenStream.LA(1) !== Tokens.EOF){
22472247
this._unexpectedToken(this._tokenStream.LT(1));
22482248
}
22492249
},

src/css/PropertyValuePart.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ function PropertyValuePart(text, line, col){
9393
} else if (/^#([a-f0-9]{3,6})/i.test(text)){ //hexcolor
9494
this.type = "color";
9595
temp = RegExp.$1;
96-
if (temp.length == 3){
96+
if (temp.length === 3){
9797
this.red = parseInt(temp.charAt(0)+temp.charAt(0),16);
9898
this.green = parseInt(temp.charAt(1)+temp.charAt(1),16);
9999
this.blue = parseInt(temp.charAt(2)+temp.charAt(2),16);

src/css/Pseudos.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ Pseudos.ELEMENT = 1;
99
Pseudos.CLASS = 2;
1010

1111
Pseudos.isElement = function(pseudo){
12-
return pseudo.indexOf("::") === 0 || Pseudos[pseudo.toLowerCase()] == Pseudos.ELEMENT;
13-
};
12+
return pseudo.indexOf("::") === 0 || Pseudos[pseudo.toLowerCase()] === Pseudos.ELEMENT;
13+
};

src/css/Specificity.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Specificity.calculate = function(selector){
7979
elementName = part.elementName ? part.elementName.text : "",
8080
modifier;
8181

82-
if (elementName && elementName.charAt(elementName.length-1) != "*") {
82+
if (elementName && elementName.charAt(elementName.length-1) !== "*") {
8383
d++;
8484
}
8585

0 commit comments

Comments
 (0)