Skip to content

Commit fdc577d

Browse files
authored
feat: Ignore html comments (#183)
1 parent 12efbe3 commit fdc577d

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ declare const htmx: typeof htmxType;
4444
response = full;
4545
}
4646

47+
// Skip comment-only chunks (heartbeats), but allow empty chunks through
48+
const hasComment = /<!--[\s\S]*?-->/.test(response);
49+
const stripped = response.replace(/<!--[\s\S]*?-->/g, "").trim();
50+
if (hasComment && stripped.length === 0) return;
51+
4752
api.withExtensions(elt, function (extension) {
4853
if (!extension.transformResponse) return;
4954
response = extension.transformResponse(response, xhr, elt);

0 commit comments

Comments
 (0)