{"record":{"id":"1ffef64b9cd47796","repo":"swc-project/swc","slug":"headingwhenheadingopen","errorCode":"HeadingWhenHeadingOpen","errorMessage":"Heading cannot be a child of another heading","messagePattern":"Heading cannot be a child of another heading","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"crates/swc_html_parser/src/parser/mod.rs","lineNumber":2799,"sourceCode":"                    //\n                    // Insert an HTML element for the token.\n                    Token::StartTag {\n                        tag_name,\n                        is_self_closing,\n                        ..\n                    } if matches!(&**tag_name, \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\") => {\n                        if self.open_elements_stack.has_in_button_scope(\"p\") {\n                            self.close_p_element(token_and_info, false);\n                        }\n\n                        match self.open_elements_stack.items.last() {\n                            Some(node)\n                                if is_html_element!(\n                                    node,\n                                    \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\"\n                                ) =>\n                            {\n                                self.errors.push(Error::new(\n                                    token_and_info.span,\n                                    ErrorKind::HeadingWhenHeadingOpen,\n                                ));\n\n                                self.open_elements_stack.pop();\n                            }\n                            _ => {}\n                        }\n\n                        self.insert_html_element(token_and_info)?;\n                        maybe_allow_self_closing!(is_self_closing, tag_name);\n                    }\n                    // A start tag whose tag name is one of: \"pre\", \"listing\"\n                    //\n                    // If the stack of open elements has a p element in button scope, then close a p\n                    // element.\n                    //\n                    // Insert an HTML element for the token.","sourceCodeStart":2781,"sourceCodeEnd":2817,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_html_parser/src/parser/mod.rs#L2781-L2817","documentation":"HTML parse error in 'in body': a start tag h1-h6 was seen while the current node is also a heading element, i.e. a heading nested directly inside another heading, which is invalid. The parser still closes the current heading and inserts the new one.","triggerScenarios":"Thrown at crates/swc_html_parser/src/parser/mod.rs:2799 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Close the outer heading before starting another (e.g. <h1>a<h2>b -> <h1>a</h1><h2>b)","Use a non-heading container element for the nested structure"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}