{"record":{"id":"c16cc5110109f1ed","repo":"alibaba/page-agent","slug":"error-checking-text-node-visibility","errorCode":null,"errorMessage":"Error checking text node visibility:","messagePattern":"Error checking text node visibility:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/page-controller/src/dom/dom_tree/index.js","lineNumber":632,"sourceCode":"\t\t\t\treturn false\n\t\t\t}\n\n\t\t\t// Check parent visibility\n\t\t\tconst parentElement = textNode.parentElement\n\t\t\tif (!parentElement) return false\n\n\t\t\ttry {\n\t\t\t\treturn parentElement.checkVisibility({\n\t\t\t\t\tcheckOpacity: true,\n\t\t\t\t\tcheckVisibilityCSS: true,\n\t\t\t\t})\n\t\t\t} catch (e) {\n\t\t\t\t// Fallback if checkVisibility is not supported\n\t\t\t\tconst style = window.getComputedStyle(parentElement)\n\t\t\t\treturn style.display !== 'none' && style.visibility !== 'hidden' && style.opacity !== '0'\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tconsole.warn('Error checking text node visibility:', e)\n\t\t\treturn false\n\t\t}\n\t}\n\n\t/**\n\t * Checks if an element is accepted.\n\t *\n\t * @param {HTMLElement} element - The element to check.\n\t * @returns {boolean} Whether the element is accepted.\n\t */\n\tfunction isElementAccepted(element) {\n\t\tif (!element || !element.tagName) return false\n\n\t\t// Always accept body and common container elements\n\t\tconst alwaysAccept = new Set([\n\t\t\t'body',\n\t\t\t'div',\n\t\t\t'main',","sourceCodeStart":614,"sourceCodeEnd":650,"githubUrl":"https://github.com/alibaba/page-agent/blob/d02db1ee7c41f5315beda88bab2fe935c580f662/packages/page-controller/src/dom/dom_tree/index.js#L614-L650","documentation":"During DOM tree construction, isTextNodeVisible wraps visibility checks (checkVisibility plus a getComputedStyle fallback) in try/catch; any unexpected exception while inspecting a text node's parent logs this warning and the node is treated as invisible. It is a non-fatal warning so one bad node never breaks the whole page extraction.","triggerScenarios":"The parent element is in a detached document or a cross-origin iframe where getComputedStyle/checkVisibility throws; exotic or polyfilled DOM environments; nodes removed mid-traversal so their parent becomes null; jsdom or other non-browser DOM lacking full APIs.","commonSituations":"Pages with cross-origin iframes; heavy mutation during scraping causing races; test environments (jsdom) with partial CSSOM support; older browsers without checkVisibility where the fallback itself throws.","solutions":["Treat as benign: the node is skipped, extraction continues; verify your extraction still contains the content you need","If content is missing, re-run updateTree() when the page is more settled (after load/spinner completes)","Upgrade to a modern browser so checkVisibility is used instead of the throwing fallback","If it floods logs, debounce updateTree calls and avoid indexing during heavy DOM mutation"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat the warning as non-fatal; verify extraction completeness separately","Index after page load settles (spinners done) to reduce races","Run in a modern browser so checkVisibility is available","Avoid interleaving updateTree() with heavy DOM mutations"],"tags":["dom","visibility","non-fatal","page-controller"],"backgroundTag":"dom-visibility-check-failed","analyzedSha":"d02db1ee7c41f5315beda88bab2fe935c580f662","analyzedAt":"2026-08-28T19:39:48.634Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}