mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Properly coalesce whitespace when given a reference child (fixes #15979)
This commit is contained in:
parent
0a0fb61b48
commit
0d904e387e
2 changed files with 6 additions and 13 deletions
|
@ -657,7 +657,12 @@ fn insert(parent: &Node, reference_child: Option<&Node>, child: NodeOrText<JS<No
|
|||
parent.InsertBefore(&n, reference_child).unwrap();
|
||||
},
|
||||
NodeOrText::AppendText(t) => {
|
||||
if let Some(text) = parent.GetLastChild().and_then(Root::downcast::<Text>) {
|
||||
let text = reference_child
|
||||
.and_then(Node::GetPreviousSibling)
|
||||
.or_else(|| parent.GetLastChild())
|
||||
.and_then(Root::downcast::<Text>);
|
||||
|
||||
if let Some(text) = text {
|
||||
text.upcast::<CharacterData>().append_data(&t);
|
||||
} else {
|
||||
let text = Text::new(String::from(t).into(), &parent.owner_doc());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue