mirror of
https://github.com/servo/servo.git
synced 2025-06-08 08:33:26 +00:00
Implement ProcessingInstruction DOM interface
Spec: http://dom.spec.whatwg.org/#interface-processinginstruction Closes #1619.
This commit is contained in:
parent
5a7d22c437
commit
aa4b5bb948
8 changed files with 153 additions and 56 deletions
|
@ -5,7 +5,9 @@
|
|||
use servo_util::namespace;
|
||||
use dom::attr::Attr;
|
||||
use dom::node::NodeIterator;
|
||||
use dom::node::{DoctypeNodeTypeId, DocumentFragmentNodeTypeId, CommentNodeTypeId, DocumentNodeTypeId, ElementNodeTypeId, TextNodeTypeId, AbstractNode};
|
||||
use dom::node::{DoctypeNodeTypeId, DocumentFragmentNodeTypeId, CommentNodeTypeId};
|
||||
use dom::node::{DocumentNodeTypeId, ElementNodeTypeId, ProcessingInstructionNodeTypeId};
|
||||
use dom::node::{TextNodeTypeId, AbstractNode};
|
||||
|
||||
pub fn serialize(iterator: &mut NodeIterator) -> ~str {
|
||||
let mut html = ~"";
|
||||
|
@ -29,6 +31,9 @@ pub fn serialize(iterator: &mut NodeIterator) -> ~str {
|
|||
DoctypeNodeTypeId => {
|
||||
serialize_doctype(node)
|
||||
}
|
||||
ProcessingInstructionNodeTypeId => {
|
||||
serialize_processing_instruction(node)
|
||||
}
|
||||
DocumentFragmentNodeTypeId => {
|
||||
~""
|
||||
}
|
||||
|
@ -70,6 +75,12 @@ fn serialize_text(node: AbstractNode) -> ~str {
|
|||
})
|
||||
}
|
||||
|
||||
fn serialize_processing_instruction(node: AbstractNode) -> ~str {
|
||||
node.with_imm_processing_instruction(|processing_instruction| {
|
||||
~"<?" + processing_instruction.target + " " + processing_instruction.element.data + "?>"
|
||||
})
|
||||
}
|
||||
|
||||
fn serialize_doctype(node: AbstractNode) -> ~str {
|
||||
node.with_imm_doctype(|doctype| {
|
||||
~"<!DOCTYPE" + doctype.name + ">"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue