Now passing output tests as well as anyone

This commit is contained in:
Patrick Shaughnessy 2020-01-01 13:33:19 -05:00
parent fd2950e903
commit a322c6079b
9 changed files with 67 additions and 54 deletions

View file

@ -2017,6 +2017,16 @@ impl Node {
parent.owner_doc().remove_script_and_layout_blocker();
}
// https://dom.spec.whatwg.org/multipage/#string-replace-all
pub fn string_replace_all(string: DOMString, parent: &Node) {
if string.len() == 0 {
Node::replace_all(None, parent);
} else {
let text = Text::new(string, &document_from_node(parent));
Node::replace_all(Some(text.upcast::<Node>()), parent);
};
}
// https://dom.spec.whatwg.org/#concept-node-pre-remove
fn pre_remove(child: &Node, parent: &Node) -> Fallible<DomRoot<Node>> {
// Step 1.
@ -2213,6 +2223,11 @@ impl Node {
Node::collect_text_contents(self.children())
}
/// <https://html.spec.whatwg.org/multipage/#descendant-text-content>
pub fn descendant_text_content(&self) -> DOMString {
Node::collect_text_contents(self.traverse_preorder(ShadowIncluding::No))
}
pub fn collect_text_contents<T: Iterator<Item = DomRoot<Node>>>(iterator: T) -> DOMString {
let mut content = String::new();
for node in iterator {