test: simplify export html specificity count · openclaw/openclaw@df1851b
steipete
·
2026-05-09
·
via Recent Commits to openclaw:main
File tree
src/auto-reply/reply/export-html
| Original file line number | Diff line number | Diff line change |
|---|
@@ -145,9 +145,12 @@ function selectorSpecificity(selector: string): [number, number, number] {
|
145 | 145 | const ids = selector.match(/#[\w-]+/g)?.length ?? 0; |
146 | 146 | const classes = selector.match(/\.[\w-]+/g)?.length ?? 0; |
147 | 147 | const withoutIdsOrClasses = selector.replace(/#[\w-]+|\.[\w-]+/g, " "); |
148 | | -const elements = withoutIdsOrClasses |
149 | | -.split(/[\s>+~]+/) |
150 | | -.filter((part) => /^[a-z][\w-]*$/i.test(part)).length; |
| 148 | +let elements = 0; |
| 149 | +for (const part of withoutIdsOrClasses.split(/[\s>+~]+/)) { |
| 150 | +if (/^[a-z][\w-]*$/i.test(part)) { |
| 151 | +elements++; |
| 152 | +} |
| 153 | +} |
151 | 154 | return [ids, classes, elements]; |
152 | 155 | } |
153 | 156 | |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。