diff --git a/ts/highlighter/chtml_highlighter.ts b/ts/highlighter/chtml_highlighter.ts
index 0df5a87ec..8c7179294 100644
--- a/ts/highlighter/chtml_highlighter.ts
+++ b/ts/highlighter/chtml_highlighter.ts
@@ -32,7 +32,7 @@ export class ChtmlHighlighter extends CssHighlighter {
* @override
*/
public isMactionNode(node: HTMLElement) {
- return node.tagName.toUpperCase() === this.mactionName.toUpperCase();
+ return node.tagName?.toUpperCase() === this.mactionName.toUpperCase();
}
/**