DomUtil optimize (#350)

This commit is contained in:
LawyZheng
2024-05-21 10:49:21 +08:00
committed by GitHub
parent 0719396136
commit f86097fc78

View File

@@ -758,8 +758,10 @@ function buildTreeFromBody() {
} }
} }
// character length limit for non-interactable elements should be 100 // character length limit for non-interactable elements should be 5000
if (textContent && textContent.length <= 100) { // we don't use element context in HTML format,
// so we need to make sure we parse all text node to avoid missing text in HTML.
if (textContent && textContent.length <= 5000) {
var elementObj = buildElementObject(element, false); var elementObj = buildElementObject(element, false);
elements.push(elementObj); elements.push(elementObj);
if (parentId === null) { if (parentId === null) {
@@ -991,7 +993,8 @@ function buildTreeFromBody() {
element.context = context; element.context = context;
} }
if (checkStringIncludeRequire(context)) { // FIXME: skip <a> for now to prevent navigating to other page by mistake
if (element.tagName !== "a" && checkStringIncludeRequire(context)) {
if ( if (
!element.attributes["required"] && !element.attributes["required"] &&
!element.attributes["aria-required"] !element.attributes["aria-required"]