diff --git a/src/auto-reply/reply/export-html/template.security.test.ts b/src/auto-reply/reply/export-html/template.security.test.ts
index 2be2f256c78..ec6b3cc123f 100644
--- a/src/auto-reply/reply/export-html/template.security.test.ts
+++ b/src/auto-reply/reply/export-html/template.security.test.ts
@@ -145,9 +145,12 @@ function selectorSpecificity(selector: string): [number, number, number] {
const ids = selector.match(/#[\w-]+/g)?.length ?? 0;
const classes = selector.match(/\.[\w-]+/g)?.length ?? 0;
const withoutIdsOrClasses = selector.replace(/#[\w-]+|\.[\w-]+/g, " ");
- const elements = withoutIdsOrClasses
- .split(/[\s>+~]+/)
- .filter((part) => /^[a-z][\w-]*$/i.test(part)).length;
+ let elements = 0;
+ for (const part of withoutIdsOrClasses.split(/[\s>+~]+/)) {
+ if (/^[a-z][\w-]*$/i.test(part)) {
+ elements++;
+ }
+ }
return [ids, classes, elements];
}