Skip to content

Commit

Permalink
refactor: systematically use comparison with undefined
Browse files Browse the repository at this point in the history
Compare the return value of functions that return a code point or ``undefined``
with ``undefined`` (``c === undefined``) instead of just doing ``!c``.
  • Loading branch information
lddubeau committed Sep 12, 2019
1 parent c1fed89 commit fff5edb
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions lib/saxes.js
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ class SaxesParser {
if (c === LESS) {
this.state = S_OPEN_WAKA;
}
else if (c) {
else if (c !== undefined) {
// have to process this as a text node.
// weird, but happens.
if (!this.reportedTextBeforeRoot) {
Expand Down Expand Up @@ -1216,7 +1216,7 @@ class SaxesParser {
this.ondoctype(this.doctype);
this.doctype = true; // just remember that we saw it.
}
else if (c) {
else if (c !== undefined) {
this.doctype += String.fromCodePoint(c);
if (c === OPEN_BRACKET) {
this.state = S_DTD;
Expand All @@ -1241,7 +1241,7 @@ class SaxesParser {
/** @private */
sDTD() {
const c = this.captureTo(DTD_TERMINATOR, "doctype");
if (!c) {
if (c === undefined) {
return;
}

Expand Down Expand Up @@ -1450,7 +1450,7 @@ class SaxesParser {
}
this.state = c === QUESTION ? S_PI_ENDING : S_PI_BODY;
}
else if (c) {
else if (c !== undefined) {
this.fail("disallowed character in processing instruction name.");
this.piTarget += String.fromCodePoint(c);
}
Expand Down Expand Up @@ -1556,7 +1556,7 @@ class SaxesParser {
return;
}

if (c) {
if (c !== undefined) {
switch (this.xmlDeclName) {
case "version": {
this.xmlDeclExpects = ["encoding", "standalone"];
Expand Down Expand Up @@ -1675,7 +1675,7 @@ class SaxesParser {
/** @private */
sOpenTag() {
const c = this.captureNameChars();
if (!c) {
if (c === undefined) {
return;
}

Expand Down Expand Up @@ -1727,7 +1727,7 @@ class SaxesParser {
/** @private */
sAttrib() {
const c = this.skipSpaces();
if (!c) {
if (c === undefined) {
return;
}
if (isNameStartChar(c)) {
Expand Down Expand Up @@ -1799,15 +1799,15 @@ class SaxesParser {
this.name = this.text = "";
this.openTag();
}
else if (c) {
else if (c !== undefined) {
this.fail("disallowed character in attribute name.");
}
}

/** @private */
sAttribNameSawWhite() {
const c = this.skipSpaces();
if (!c) {
if (c === undefined) {
return;
}

Expand Down Expand Up @@ -1919,7 +1919,7 @@ class SaxesParser {
else if (c === LESS) {
this.fail("disallowed character.");
}
else if (c) {
else if (c !== undefined) {
if (this.text.includes("]]>")) {
this.fail("the string \"]]>\" is disallowed in char data.");
}
Expand All @@ -1943,7 +1943,7 @@ class SaxesParser {
else if (isS(c)) {
this.state = S_CLOSE_TAG_SAW_WHITE;
}
else if (c) {
else if (c !== undefined) {
this.fail("disallowed character in closing tag.");
}
}
Expand All @@ -1954,7 +1954,7 @@ class SaxesParser {
if (c === GREATER) {
this.closeTag();
}
else if (c) {
else if (c !== undefined) {
this.fail("disallowed character in closing tag.");
}
}
Expand Down

0 comments on commit fff5edb

Please sign in to comment.