{"record":{"id":"fef642d746852b18","repo":"swc-project/swc","slug":"tag-name-start-tag-with-select-open","errorCode":null,"errorMessage":"\"{tag_name}\" start tag with \"select\" open","messagePattern":"\"(.+?)\" start tag with \"select\" open","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"crates/swc_html_parser/src/parser/mod.rs","lineNumber":5877,"sourceCode":"                    // A start tag whose tag name is one of: \"input\", \"keygen\", \"textarea\"\n                    //\n                    // Parse error.\n                    //\n                    // If the stack of open elements does not have a select element in select scope,\n                    // ignore the token. (fragment case)\n                    //\n                    // Otherwise:\n                    //\n                    // Pop elements from the stack of open elements until a select element has been\n                    // popped from the stack.\n                    //\n                    // Reset the insertion mode appropriately.\n                    //\n                    // Reprocess the token.\n                    Token::StartTag { tag_name, .. }\n                        if matches!(&**tag_name, \"input\" | \"keygen\" | \"textarea\") =>\n                    {\n                        self.errors.push(Error::new(\n                            token_and_info.span,\n                            ErrorKind::StartTagWithSelectOpen(tag_name.clone()),\n                        ));\n\n                        if !self.open_elements_stack.has_in_select_scope(\"select\") {\n                            // Ignore\n                            return Ok(());\n                        }\n\n                        self.open_elements_stack\n                            .pop_until_tag_name_popped(&[\"select\"]);\n                        self.reset_insertion_mode();\n                        self.process_token(token_and_info, None)?;\n                    }\n                    // A start tag whose tag name is one of: \"script\", \"template\"\n                    //\n                    // An end tag whose tag name is \"template\"\n                    //","sourceCodeStart":5859,"sourceCodeEnd":5895,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_html_parser/src/parser/mod.rs#L5859-L5895","documentation":"A start tag for `input`, `keygen`, or `textarea` was seen while a `<select>` is open. HTML5 defines this as a parse error; the parser pops the select, resets the insertion mode, and reprocesses the token so the control lands after the select. Browsers behave the same way — form controls cannot live inside select.","triggerScenarios":"`<select><input type=\"text\"></select>`, `<select><textarea>x</textarea></select>`, or `<keygen>` inside select markup — typically a form template that placed the control between the option list tags.","commonSituations":"Form builders emitting controls in the wrong container; conditional form fields rendered inside a select block; refactors moving an input into select markup; `keygen` in legacy markup.","solutions":["Move the `<input>`/`<textarea>`/`<keygen>` outside the `<select>…</select>` region.","Fix the form template so each control is emitted in its own container, not inside the options block.","Pre-scan generated markup: reject `<input`, `<textarea`, or `<keygen` between `<select` and `</select`.","Recovery closes the select first, so the tree is still usable — log `StartTagWithSelectOpen` from the `errors` vec."],"exampleFix":"<!-- before -->\n<select><input type=\"text\"></select>\n\n<!-- after -->\n<select></select>\n<input type=\"text\">","handlingStrategy":"validation","validationCode":"// Pre-check: form controls must not appear between <select and </select\nfn control_inside_select(html: &str) -> Option<&'static str> {\n    let lower = html.to_ascii_lowercase();\n    let start = lower.find(\"<select\")?;\n    let end = lower[start..].find(\"</select\").map(|n| start + n)?;\n    let inner = &lower[start..end];\n    [\"<input\", \"<keygen\", \"<textarea\"]\n        .into_iter()\n        .find(|t| inner.contains(t))\n}","typeGuard":"use swc_html_parser::error::{Error, ErrorKind};\n\nfn is_control_inside_select(err: &Error) -> bool {\n    matches!(\n        err.kind(),\n        ErrorKind::StartTagWithSelectOpen(t) if matches!(&**t, \"input\" | \"keygen\" | \"textarea\")\n    )\n}","tryCatchPattern":"let mut errors = Vec::new();\nlet doc = parse_file_as_document(&fm, config, &mut errors)?;\nfor e in &errors {\n    if let ErrorKind::StartTagWithSelectOpen(tag) = e.kind() {\n        // select was closed before this control; it now sits after the select — log/verify\n    }\n}","preventionTips":["Place <input>/<textarea>/<keygen> outside <select>…</select> in form templates.","Add a pre-scan for form controls inside select regions to your template test suite.","Review conditional form-field blocks that were moved near option lists.","Check the recovered tree: the control ends up after the select (spec behavior)."],"tags":["html","html-parser","select","form-controls","parse-error","swc"],"backgroundTag":"input-inside-select","analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}