From 5a1864643f22f1eff39180a5e57b71fe8b7a41e8 Mon Sep 17 00:00:00 2001 From: Siyuan Yan <44753941+Madoshakalaka@users.noreply.github.com> Date: Tue, 12 Aug 2025 21:03:57 +0900 Subject: [PATCH] apply attributes before inserting elements into the DOM (#3892) --- packages/yew/src/dom_bundle/btag/mod.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/yew/src/dom_bundle/btag/mod.rs b/packages/yew/src/dom_bundle/btag/mod.rs index e2520f2ec..5eeda1fc9 100644 --- a/packages/yew/src/dom_bundle/btag/mod.rs +++ b/packages/yew/src/dom_bundle/btag/mod.rs @@ -123,11 +123,16 @@ impl Reconcilable for VTag { key, .. } = self; - slot.insert(parent, &el); + // Apply attributes BEFORE inserting the element into the DOM + // This is crucial for SVG animation elements where the animation + // starts immediately upon DOM insertion let attributes = attributes.apply(root, &el); let listeners = listeners.apply(root, &el); + // Now insert the element with attributes already set + slot.insert(parent, &el); + let inner = match self.inner { VTagInner::Input(f) => { let f = f.apply(root, el.unchecked_ref());