{"record":{"id":"e6829ceb78379b44","repo":"leptos-rs/leptos","slug":"inertelement-does-not-support-adding-attributes-i","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/html/mod.rs","lineNumber":170,"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":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/leptos-rs/leptos/blob/32d20f6c9d517451d77beb68d88c7716823dac41/tachys/src/html/mod.rs#L152-L188","documentation":"InertElement is a static HTML element that renders its tags and attributes as raw, pre-rendered strings without owning typed attribute keys. Because it discards attribute metadata, the framework cannot implement add_any_attr for it, so calling that method panics. The message hints that this element type is only valid nested inside another view, never as a top-level return that would need attributes attached later.","triggerScenarios":"Calling .add_any_attr(...) on an InertElement, or returning an InertElement from a component/view at the top level where the framework tries to attach attributes to it.","commonSituations":"Wrapping hand-written static HTML strings (e.g. via the inert/raw element path) and then trying to add dynamic attributes like class or event directives; using an inert element as a component's root view and adding attributes at the call site.","solutions":["Convert the static markup into a typed element (e.g. the corresponding html::element from tachys/leptos) so attributes can be added.","Wrap the InertElement in a parent element and keep it strictly as a child, adding attributes to the parent instead.","If you need raw HTML plus attributes, render the raw string as the inner content of a typed element rather than using InertElement at the top level."],"exampleFix":"// before\nInertElement::new(\"<span>hi</span>\").add_any_attr(class(\"bold\"))\n// after\nlet el = html::span().attr(class(\"bold\")).child(\"hi\");","handlingStrategy":"validation","validationCode":"fn supports_attrs<V: RenderHtml>(v: &V) -> bool { !matches!(v as &dyn std::any::Any, _ if std::any::TypeId::of::<V>() == std::any::TypeId::of::<tachys::html::InertElement>()) }","typeGuard":"fn is_inert<V: 'static>(_v: &V) -> bool { std::any::TypeId::of::<V>() == std::any::TypeId::of::<tachys::html::InertElement>() }","tryCatchPattern":null,"preventionTips":["Never return InertElement as a view root; always nest it inside a typed element.","Prefer typed html:: elements whenever you need to attach attributes.","Keep raw-HTML helpers isolated in a module that only renders children."],"tags":["ssr","html-rendering","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"}