Skip to content

Commit 2d92af4

Browse files
committed
feat(DqElement): Edge case for void elements
Handles an edge case where element itself is small and a void element but children are longer
1 parent ac31a38 commit 2d92af4

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lib/core/utils/dq-element.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,13 @@ export function truncateElement(element) {
4343
let str = getOuterHtml(shallowNode);
4444

4545
if (str.length < maxLen) {
46-
const endingTagIndex = str.lastIndexOf('<');
47-
str = str.substring(0, endingTagIndex);
46+
let attrString = '';
47+
for (const { name, value } of elementNodeMap) {
48+
const attr = { name, value };
49+
attrString += ` ${attr.name}="${attr.value}"`;
50+
}
51+
52+
str = `<${nodeName}${attrString}>`;
4853
return str;
4954
}
5055
let strLen = `<${nodeName}>`.length;
@@ -55,8 +60,8 @@ export function truncateElement(element) {
5560
}
5661

5762
const attr = { name, value };
58-
let attrName = attr.name,
59-
attrValue = attr.value;
63+
let attrName = attr.name;
64+
let attrValue = attr.value;
6065

6166
attrName =
6267
attrName.length > maxAttrNameOrValueLen

0 commit comments

Comments
 (0)