{"record":{"id":"fa4acb89857e3a66","repo":"leptos-rs/leptos","slug":"inertelement-does-not-support-adding-attributes-i-fa4acb","errorCode":null,"errorMessage":"InertElement does not support adding attributes. It should only be used as a child, and not returned at the top level.","messagePattern":"InertElement does not support adding attributes\\. It should only be used as a child, and not returned at the top level\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tachys/src/svg/mod.rs","lineNumber":259,"sourceCode":"            el.insert_before_this(&mut new_el);\n            el.unmount();\n            *el = new_el;\n            *prev = self.html;\n        }\n    }\n}\n\nimpl AddAnyAttr for InertElement {\n    type Output<SomeNewAttr: Attribute> = Self;\n\n    fn add_any_attr<NewAttr: Attribute>(\n        self,\n        _attr: NewAttr,\n    ) -> Self::Output<NewAttr>\n    where\n        Self::Output<NewAttr>: RenderHtml,\n    {\n        panic!(\n            \"InertElement does not support adding attributes. It should only \\\n             be used as a child, and not returned at the top level.\"\n        )\n    }\n}\n\nimpl RenderHtml for InertElement {\n    type AsyncOutput = Self;\n    type Owned = Self;\n\n    const MIN_LENGTH: usize = 0;\n\n    fn html_len(&self) -> usize {\n        self.html.len()\n    }\n\n    fn dry_resolve(&mut self) {}\n","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/leptos-rs/leptos/blob/32d20f6c9d517451d77beb68d88c7716823dac41/tachys/src/svg/mod.rs#L241-L277","documentation":"Identical to the HTML variant but for SVG: the SVG InertElement type stores pre-rendered markup as raw strings and cannot accept typed attributes, so add_any_attr panics. It is meant to be embedded as a child of another view only.","triggerScenarios":"Calling add_any_attr on an SVG InertElement, or returning it at the top level of a view/component where attribute attachment is attempted.","commonSituations":"Embedding raw SVG markup strings and then trying to attach class/id/event attributes; using raw SVG snippets as component roots.","solutions":["Use tachys/leptos typed SVG elements (svg::path(), svg::circle(), etc.) so attributes are supported.","Keep the inert SVG markup strictly as a child and add attributes to a typed wrapping element.","Inline the needed attributes directly into the raw SVG string if it must remain inert."],"exampleFix":"// before\nInertElement::new(\"<path d='...'/>\").add_any_attr(class(\"icon\"))\n// after\nsvg::path().attr(class(\"icon\")).attr(d(\"M0 0 L10 10\"))","handlingStrategy":"type-guard","validationCode":"fn svg_element_accepts_attrs<T: 'static>(_t: &T) -> bool { std::any::TypeId::of::<T>() != std::any::TypeId::of::<tachys::svg::InertElement>() }","typeGuard":"fn is_svg_inert<T: 'static>(_v: &T) -> bool { std::any::TypeId::of::<T>() == std::any::TypeId::of::<tachys::svg::InertElement>() }","tryCatchPattern":null,"preventionTips":["Use typed svg:: elements when attributes are needed.","Bake attributes directly into raw SVG strings.","Never use inert SVG markup as a component root view."],"tags":["ssr","svg","static-elements"],"backgroundTag":"inert-element-attribute-unsupported","analyzedSha":"32d20f6c9d517451d77beb68d88c7716823dac41","analyzedAt":"2026-09-01T18:55:42.580Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T01:17:15.007Z"}