DomUtil optimize (#350)

This commit is contained in:
LawyZheng 2024-05-21 10:49:21 +08:00 committed by GitHub
parent 0719396136
commit f86097fc78
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -758,8 +758,10 @@ function buildTreeFromBody() {
}
}
// character length limit for non-interactable elements should be 100
if (textContent && textContent.length <= 100) {
// character length limit for non-interactable elements should be 5000
// 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);
elements.push(elementObj);
if (parentId === null) {
@ -991,7 +993,8 @@ function buildTreeFromBody() {
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 (
!element.attributes["required"] &&
!element.attributes["aria-required"]