{"record":{"id":"a965af1958592669","repo":"swc-project/swc","slug":"formwhenformopen","errorCode":"FormWhenFormOpen","errorMessage":"Saw a \"form\" start tag, but there was already an active \"form\" element, nested forms are not allowed","messagePattern":"Saw a \"form\" start tag, but there was already an active \"form\" element, nested forms are not allowed","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"crates/swc_html_parser/src/parser/mod.rs","lineNumber":2864,"sourceCode":"                    //\n                    // Otherwise:\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, and, if there is no template element on\n                    // the stack of open elements, set the form element pointer to point to the\n                    // element created.\n                    Token::StartTag {\n                        tag_name,\n                        is_self_closing,\n                        ..\n                    } if tag_name == \"form\" => {\n                        if self.form_element_pointer.is_some()\n                            && !self.open_elements_stack.contains_template_element()\n                        {\n                            self.errors\n                                .push(Error::new(token_and_info.span, ErrorKind::FormWhenFormOpen));\n\n                            return Ok(());\n                        }\n\n                        if self.open_elements_stack.has_in_button_scope(\"p\") {\n                            self.close_p_element(token_and_info, false);\n                        }\n\n                        let element = self.insert_html_element(token_and_info)?;\n\n                        if !self.open_elements_stack.contains_template_element() {\n                            self.form_element_pointer = Some(element);\n                        }\n\n                        maybe_allow_self_closing!(is_self_closing, tag_name);\n                    }\n                    // A start tag whose tag name is \"li\"\n                    //","sourceCodeStart":2846,"sourceCodeEnd":2882,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_html_parser/src/parser/mod.rs#L2846-L2882","documentation":"HTML parse error: a <form> start tag was encountered while the form element pointer is already set (an active open form exists), and nested forms are disallowed. Per spec the error is recorded and the new form element is inserted but the form pointer is left unchanged (except inside template).","triggerScenarios":"Thrown at crates/swc_html_parser/src/parser/mod.rs:2864 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Close the outer <form> before opening another","Replace nesting with sibling forms or use a different container"],"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"}