Skip to content

Commit 1639635

Browse files
committed
vlist: make placeholder keyed
1 parent a40faf4 commit 1639635

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

yew/src/virtual_dom/vlist.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! This module contains fragments implementation.
2-
use super::{Key, VDiff, VNode, VText};
2+
use super::{Key, VDiff, VNode, VTag};
33
use crate::html::{AnyScope, NodeRef};
44
use cfg_if::cfg_if;
55
use std::collections::HashMap;
@@ -302,8 +302,10 @@ impl VDiff for VList {
302302
if self.children.is_empty() {
303303
// Without a placeholder the next element becomes first
304304
// and corrupts the order of rendering
305-
// We use empty text element to stake out a place
306-
self.add_child(VText::new("").into());
305+
// We use empty span element to stake out a place
306+
let mut placeholder = VTag::new("span");
307+
placeholder.key = Some("__placeholder".into());
308+
self.children = vec![placeholder.into()];
307309
}
308310

309311
let lefts = &mut self.children;

0 commit comments

Comments
 (0)