author | Anthony Ramine <n.oxyde@gmail.com> |
Fri, 17 Mar 2017 04:25:20 -0700 | |
changeset 348150 | 1da2122f3597fc4ab0c913152f98c47ee1b4ec99 |
parent 348149 | bb5c698bff0a4d73ee015230818faacc587b07d5 |
child 348151 | 0d33d81b075fc1cdc2c497efdd43346b89864604 |
push id | 39078 |
push user | servo-vcs-sync@mozilla.com |
push date | Fri, 17 Mar 2017 12:53:34 +0000 |
treeherder | autoland@1da2122f3597 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | KiChjang |
milestone | 55.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/servo/components/script/dom/servoparser/mod.rs +++ b/servo/components/script/dom/servoparser/mod.rs @@ -652,17 +652,22 @@ pub struct FragmentContext<'a> { #[allow(unrooted_must_root)] fn insert(parent: &Node, reference_child: Option<&Node>, child: NodeOrText<JS<Node>>) { match child { NodeOrText::AppendNode(n) => { 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()); parent.InsertBefore(text.upcast(), reference_child).unwrap(); } }, } }