{"record":{"id":"b10b9dcf8f866272","repo":"swc-project/swc","slug":"saw-a-start-tag-image-img-element-is-outdated","errorCode":null,"errorMessage":"Saw a start tag \"image\", \"img\" element is outdated","messagePattern":"Saw a start tag \"image\", \"img\" element is outdated","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"crates/swc_html_parser/src/parser/mod.rs","lineNumber":3886,"sourceCode":"                        if self.open_elements_stack.has_in_button_scope(\"p\") {\n                            self.close_p_element(token_and_info, false);\n                        }\n\n                        self.insert_html_element(token_and_info)?;\n                        self.open_elements_stack.pop();\n\n                        if is_self_closing {\n                            token_and_info.acknowledged = true;\n                        }\n\n                        self.frameset_ok = false;\n                    }\n                    // A start tag whose tag name is \"image\"\n                    //\n                    // Parse error. Change the token's tag name to \"img\" and reprocess it. (Don't\n                    // ask.)\n                    Token::StartTag { tag_name, .. } if tag_name == \"image\" => {\n                        self.errors.push(Error::new(\n                            token_and_info.span,\n                            ErrorKind::UnexpectedImageStartTag,\n                        ));\n\n                        match token_and_info {\n                            TokenAndInfo {\n                                token: Token::StartTag { tag_name, .. },\n                                ..\n                            } => {\n                                *tag_name = atom!(\"img\");\n                            }\n                            _ => {\n                                unreachable!();\n                            }\n                        }\n\n                        self.process_token(token_and_info, None)?;\n                    }","sourceCodeStart":3868,"sourceCodeEnd":3904,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_html_parser/src/parser/mod.rs#L3868-L3904","documentation":"A start tag `image` was seen (parser/mod.rs:3883-3897). `image` is not an HTML element — it is a historical alias some old browsers accepted — so the spec says: parse error, rename the token's tag to `img`, and reprocess it. The parser mutates `*tag_name = atom!(\"img\")` in place, so the output tree contains an `<img>` element, but the error records that the source used the legacy spelling.","triggerScenarios":"Input containing `<image src=\"...\">`. Any `image` start tag hits this arm; attributes are kept and carried over to the synthesized `<img>`.","commonSituations":"Legacy documents from the 1990s, OCR/scraped content, and user-authored HTML where people type `<image>` thinking of the noun. Also seen when Word/old editors export HTML.","solutions":["Rename `<image>` to `<img>` in the source markup","Grep your content pipeline for `<image` and fix generators/templates","If ingesting legacy archives, accept the auto-correction (output tree is already `<img>`) and just log the error","Add a content-lint rule rejecting `image` as a tag name"],"exampleFix":"<!-- before -->\n<image src=\"logo.png\" alt=\"Logo\">\n\n<!-- after -->\n<img src=\"logo.png\" alt=\"Logo\">","handlingStrategy":"validation","validationCode":"// Replace the legacy alias before parsing\nfn normalize_image_tags(src: &str) -> String {\n    src.replace(\"<image\", \"<img\").replace(\"</image\", \"</img>\") // img is void; end tag won't occur in valid input\n}","typeGuard":"fn is_legacy_image_tag(e: &Error) -> bool {\n    matches!(e.kind, ErrorKind::UnexpectedImageStartTag)\n}","tryCatchPattern":"let doc = parser.parse_document()?;\nlet legacy = parser.take_errors().into_iter().filter(is_legacy_image_tag).count();\nif legacy > 0 { log::info!(\"{legacy} <image> tags auto-renamed to <img>\"); } // tree already correct","preventionTips":["Always use <img> in authored and generated markup","When importing legacy archives, accept the auto-rename and just log it","Content-lint pipelines should reject `image` as a tag name"],"tags":["html","parser","img","legacy-tags","typo"],"backgroundTag":"legacy-tag-alias","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"}