From 013d7ee211768a021cc2c88e0d58e662c42b7cf2 Mon Sep 17 00:00:00 2001 From: Akira Komamura <6270544+akirak@users.noreply.github.com> Date: Fri, 5 Jul 2024 02:20:11 +0900 Subject: [PATCH] fix: allow components not preceded by a comment (#56) --- src/parser.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/parser.ts b/src/parser.ts index 216eebe..30c0b90 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -22,8 +22,8 @@ export interface Data { function getComment(element: Element): string { // @ts-ignore - const prev = element.siblings[element.siblings.indexOf(element) - 1] as Element - if (prev.type === COMMENT) { + const prev = element.siblings[element.siblings.indexOf(element) - 1] as Element | undefined + if (prev?.type === COMMENT) { return (prev.children as string).trim() } return ''