diff --git a/packages/parse5/lib/parser/index.js b/packages/parse5/lib/parser/index.js index 5eececdd1fd04939a54e94344ddb3ac060653bf7..07544841686ba2f5ffd6e976970cf4c9d022a477 100644 --- a/packages/parse5/lib/parser/index.js +++ b/packages/parse5/lib/parser/index.js @@ -941,12 +941,13 @@ function checkselfClosingNode(parse, token) { * Check if the html text is legal. * @param {Object} lastToken Hml text last token information. */ -function checkInvalid(lastToken) { +function checkInvalid(parse, lastToken) { if ( lastToken.type && lastToken.type !== Tokenizer.END_TAG_TOKEN && - lastToken.type !== Tokenizer.COMMENT_TOKEN + lastToken.type !== Tokenizer.COMMENT_TOKEN && parse && parse.compileResult && + parse.compileResult.log ) { - compileResult.log.push({ + parse.compileResult.log.push({ line: lastToken.location.startLine || 1, column: lastToken.location.startCol || 1, reason: "ERROR: hml content is invalid. Please check it.",