mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Implement "child text content" concept; use it where appropriate.
This commit is contained in:
parent
872ec89a9c
commit
9073a2f4c6
4 changed files with 8 additions and 11 deletions
|
@ -8,11 +8,9 @@ use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
|||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::characterdata::CharacterData;
|
||||
use dom::document::Document;
|
||||
use dom::htmlelement::HTMLElement;
|
||||
use dom::node::{ChildrenMutation, Node};
|
||||
use dom::text::Text;
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
use html5ever_atoms::LocalName;
|
||||
|
||||
|
@ -41,13 +39,7 @@ impl HTMLTitleElement {
|
|||
impl HTMLTitleElementMethods for HTMLTitleElement {
|
||||
// https://html.spec.whatwg.org/multipage/#dom-title-text
|
||||
fn Text(&self) -> DOMString {
|
||||
let mut content = String::new();
|
||||
for child in self.upcast::<Node>().children() {
|
||||
if let Some(text) = child.downcast::<Text>() {
|
||||
content.push_str(&text.upcast::<CharacterData>().data());
|
||||
}
|
||||
}
|
||||
DOMString::from(content)
|
||||
self.upcast::<Node>().child_text_content()
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-title-text
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue