Minor cleanup of element.innerText

This commit is contained in:
Fernando Jiménez Moreno 2018-02-20 10:49:50 +01:00
parent 6a7ae3b12e
commit ff81707928
2 changed files with 10 additions and 18 deletions

View file

@ -1009,15 +1009,16 @@ fn inner_text_collection_steps<N: LayoutNode>(node: N,
}, },
Display::TableRow if !is_last_table_row() => { Display::TableRow if !is_last_table_row() => {
// Step 7. // Step 7.
items.push(InnerTextItem::Text(String::from("\u{000A}" /* line feed */))); items.push(InnerTextItem::Text(String::from(
"\u{000A}", /* line feed */
)));
}, },
_ => (), Display::Block | Display::Flex | Display::TableCaption | Display::Table => {
} // Step 9.
items.insert(0, InnerTextItem::RequiredLineBreakCount(1));
// Step 9. items.push(InnerTextItem::RequiredLineBreakCount(1));
if is_block_level_or_table_caption(&display) { },
items.insert(0, InnerTextItem::RequiredLineBreakCount(1)); _ => {},
items.push(InnerTextItem::RequiredLineBreakCount(1));
} }
} }
@ -1033,11 +1034,3 @@ fn is_last_table_row() -> bool {
// FIXME(ferjm) Implement this. // FIXME(ferjm) Implement this.
false false
} }
fn is_block_level_or_table_caption(display: &Display) -> bool {
match *display {
Display::Block | Display::Flex |
Display::TableCaption | Display::Table => true,
_ => false,
}
}

View file

@ -478,8 +478,7 @@ fn append_text_node_to_fragment(
text: String text: String
) { ) {
let text = Text::new(DOMString::from(text), document); let text = Text::new(DOMString::from(text), document);
let node = DomRoot::upcast::<Node>(text); fragment.upcast::<Node>().AppendChild(&text.upcast()).unwrap();
fragment.upcast::<Node>().AppendChild(&node).unwrap();
} }
// https://html.spec.whatwg.org/multipage/#attr-data-* // https://html.spec.whatwg.org/multipage/#attr-data-*