{"record":{"id":"60fbd48d97c7588e","repo":"oxc-project/oxc","slug":"prefer-textcontent-over-innertext","errorCode":null,"errorMessage":"Prefer `.textContent` over `.innerText`.","messagePattern":"Prefer `\\.textContent` over `\\.innerText`\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/unicorn/prefer_dom_node_text_content.rs","lineNumber":9,"sourceCode":"use oxc_ast::{AstKind, ast::PropertyKey};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\n\nuse crate::{AstNode, context::LintContext, rule::Rule};\n\nfn prefer_dom_node_text_content_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Prefer `.textContent` over `.innerText`.\")\n        .with_help(\"Replace `.innerText` with `.textContent`.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct PreferDomNodeTextContent;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Enforces the use of `.textContent` over `.innerText` for DOM nodes.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// There are some disadvantages of using `.innerText`.\n    /// - `.innerText` returns rendered text and ignores hidden content, while `.textContent` returns the node's full text content.\n    /// - `.innerText` can trigger reflow because it takes CSS styles into account.\n    /// - `.innerText` is defined only for HTMLElement objects, while `.textContent` is defined for all Node objects.","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/prefer_dom_node_text_content.rs#L1-L27","documentation":"Diagnostic from the unicorn/prefer-dom-node-text-content lint rule. It fires when `.innerText` is read or written on a DOM node. `innerText` is layout-aware (it triggers reflow and is not part of the DOM standard), while `textContent` returns all contained text cheaply and is the standard property. It is a performance/style suggestion, not a runtime error.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/unicorn/prefer_dom_node_text_content.rs:9 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Replace `.innerText` with `.textContent`","Use `textContent` when the rendered/CSS-aware semantics of `innerText` are not required","Apply the rule's auto-fix"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}