From 9eea5057e435cc38e4cf729b26599a9d55f28ef8 Mon Sep 17 00:00:00 2001 From: Danish-Belal Date: Sun, 15 Mar 2026 13:54:00 +0530 Subject: [PATCH] Add defensive Element check in HeadSnapshot.detailsByOuterHTML (fixes #1472) Filter out non-Element nodes before calling elementWithoutNonce. Text/comment nodes in head lack hasAttribute(), causing TypeError during prefetch when head contains HTML comments. Made-with: Cursor --- src/core/drive/head_snapshot.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/drive/head_snapshot.js b/src/core/drive/head_snapshot.js index 96d746514..5f9aa94db 100644 --- a/src/core/drive/head_snapshot.js +++ b/src/core/drive/head_snapshot.js @@ -4,6 +4,7 @@ import { Snapshot } from "../snapshot" export class HeadSnapshot extends Snapshot { detailsByOuterHTML = this.children .filter((element) => !elementIsNoscript(element)) + .filter((element) => element instanceof Element) .map((element) => elementWithoutNonce(element)) .reduce((result, element) => { const { outerHTML } = element