aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/servoparser
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2017-03-17 11:28:04 +0100
committerAnthony Ramine <n.oxyde@gmail.com>2017-03-17 11:40:03 +0100
commit0d904e387ee479daff30ee496fc6bc92255922fd (patch)
tree48b4facab33e9341ca773b5bd4f13d246d799825 /components/script/dom/servoparser
parent0a0fb61b4838365375b0f7cfc432cce6d475c258 (diff)
downloadservo-0d904e387ee479daff30ee496fc6bc92255922fd.tar.gz
servo-0d904e387ee479daff30ee496fc6bc92255922fd.zip
Properly coalesce whitespace when given a reference child (fixes #15979)
Diffstat (limited to 'components/script/dom/servoparser')
-rw-r--r--components/script/dom/servoparser/mod.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/components/script/dom/servoparser/mod.rs b/components/script/dom/servoparser/mod.rs
index 531f13274e6..3904910d3a3 100644
--- a/components/script/dom/servoparser/mod.rs
+++ b/components/script/dom/servoparser/mod.rs
@@ -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());