Skip to content

Commit f2af6cb

Browse files
committed
Add Comment state errors.
1 parent 4957615 commit f2af6cb

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lib/common/error_codes.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ module.exports = {
1616
malformedComment: 'malformed-comment',
1717
eofInScriptHtmlComment: 'eof-in-script-html-comment',
1818
nestedComment: 'nested-comment',
19-
abruptComment: 'abrupt-comment'
19+
abruptComment: 'abrupt-comment',
20+
eofInComment: 'eof-in-comment'
2021
};

lib/tokenizer/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1601,6 +1601,7 @@ _[COMMENT_START_DASH_STATE] = function commentStartDashState(cp) {
16011601
}
16021602

16031603
else if (cp === $.EOF) {
1604+
this._err(ERR.eofInComment);
16041605
this._emitCurrentToken();
16051606
this._emitEOFToken();
16061607
}
@@ -1623,10 +1624,13 @@ _[COMMENT_STATE] = function commentState(cp) {
16231624
this.state = COMMENT_LESS_THAN_SIGN_STATE;
16241625
}
16251626

1626-
else if (cp === $.NULL)
1627+
else if (cp === $.NULL) {
1628+
this._err(ERR.unexpectedNullCharacter);
16271629
this.currentToken.data += UNICODE.REPLACEMENT_CHARACTER;
1630+
}
16281631

16291632
else if (cp === $.EOF) {
1633+
this._err(ERR.eofInComment);
16301634
this._emitCurrentToken();
16311635
this._emitEOFToken();
16321636
}

0 commit comments

Comments
 (0)