Auto merge of #16010 - nox:h5e, r=KiChjang

Properly coalesce whitespace when given a reference child (fixes #15979)

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16010)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-03-17 04:25:20 -07:00 committed by GitHub
commit 32784c5fa8
2 changed files with 6 additions and 13 deletions

View file

@ -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());

View file

@ -1,12 +0,0 @@
[html5lib_template.html?run_type=write]
type: testharness
[html5lib_template.html?run_type=write_single]
type: testharness
[html5lib_template.html 574a95fc9c9f2de3aeaa0c9ee1e6967fc3d4770d]
expected: FAIL
bug: https://github.com/servo/servo/issues/15979
[html5lib_template.html?run_type=uri]
type: testharness