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 { - if let Some(text) = parent.GetLastChild().and_then(Root::downcast::) { + let text = reference_child + .and_then(Node::GetPreviousSibling) + .or_else(|| parent.GetLastChild()) + .and_then(Root::downcast::); + + if let Some(text) = text { text.upcast::().append_data(&t); } else { let text = Text::new(String::from(t).into(), &parent.owner_doc()); diff --git a/tests/wpt/metadata/html/syntax/parsing/html5lib_template.html.ini b/tests/wpt/metadata/html/syntax/parsing/html5lib_template.html.ini deleted file mode 100644 index d07885da2f9..00000000000 --- a/tests/wpt/metadata/html/syntax/parsing/html5lib_template.html.ini +++ /dev/null @@ -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