From e44642f4e473977e89bfab201dcfe712989f8d02 Mon Sep 17 00:00:00 2001 From: Christian Bromann Date: Thu, 21 Nov 2024 10:45:15 -0800 Subject: [PATCH] fix(mock-doc): return empty string if anchor has no href attribute (#6051) --- src/mock-doc/element.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mock-doc/element.ts b/src/mock-doc/element.ts index 4d4cf8a38eb..48db9403132 100644 --- a/src/mock-doc/element.ts +++ b/src/mock-doc/element.ts @@ -107,6 +107,9 @@ export class MockAnchorElement extends MockHTMLElement { this.setAttribute('href', value); } get pathname() { + if (!this.href) { + return ''; + } return new URL(this.href).pathname; } }