Introduce benchmark tests and improve snapshot attributes traversing (#897)

* housekeeping: refine test utils

* setup benchmark tests

* improve snapshot attributes loop perf
This commit is contained in:
yz-yu
2026-04-01 12:00:00 +08:00
committed by GitHub
parent 2887c8c7e5
commit 4cfd9db6cf
8 changed files with 215 additions and 73 deletions

View File

@@ -445,8 +445,15 @@ function serializeNode(
);
const tagName = getValidTagName(n as HTMLElement);
let attributes: attributes = {};
for (const { name, value } of Array.from((n as HTMLElement).attributes)) {
attributes[name] = transformAttribute(doc, tagName, name, value);
const len = (n as HTMLElement).attributes.length;
for (let i = 0; i < len; i++) {
const attr = (n as HTMLElement).attributes[i];
attributes[attr.name] = transformAttribute(
doc,
tagName,
attr.name,
attr.value,
);
}
// remote css
if (tagName === 'link' && inlineStylesheet) {