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
2022-05-14 14:52:26 +08:00
committed by GitHub
parent de755ae577
commit a43d4e4255
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) {