aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/dom/document.rs
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno.d@partner.samsung.com>2014-02-05 11:51:42 -0400
committerBruno de Oliveira Abinader <bruno.d@partner.samsung.com>2014-02-06 16:11:31 -0400
commitac8c659d2b770031c2d2dff020ca4c46e7df385f (patch)
treebfdd01e365c008f1a322f53fed8c1fa38f15037d /src/components/script/dom/document.rs
parent799e0ace786582f79b54d3652de5e84cd88bedbf (diff)
downloadservo-ac8c659d2b770031c2d2dff020ca4c46e7df385f.tar.gz
servo-ac8c659d2b770031c2d2dff020ca4c46e7df385f.zip
Implement document.createProcessingInstruction
Spec: http://dom.spec.whatwg.org/#dom-document-createprocessinginstruction This is a sub-task for #1428.
Diffstat (limited to 'src/components/script/dom/document.rs')
-rw-r--r--src/components/script/dom/document.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/components/script/dom/document.rs b/src/components/script/dom/document.rs
index 84343959866..7dd41f686d7 100644
--- a/src/components/script/dom/document.rs
+++ b/src/components/script/dom/document.rs
@@ -18,6 +18,7 @@ use dom::htmldocument::HTMLDocument;
use dom::mouseevent::MouseEvent;
use dom::node::{AbstractNode, Node, ElementNodeTypeId, DocumentNodeTypeId};
use dom::text::Text;
+use dom::processinginstruction::ProcessingInstruction;
use dom::uievent::UIEvent;
use dom::window::Window;
use dom::htmltitleelement::HTMLTitleElement;
@@ -276,6 +277,23 @@ impl Document {
Comment::new(data, abstract_self)
}
+ // http://dom.spec.whatwg.org/#dom-document-createprocessinginstruction
+ pub fn CreateProcessingInstruction(&self, abstract_self: AbstractDocument, target: DOMString,
+ data: DOMString) -> Fallible<AbstractNode> {
+ // Step 1.
+ if xml_name_type(target) == InvalidXMLName {
+ return Err(InvalidCharacter);
+ }
+
+ // Step 2.
+ if data.contains("?>") {
+ return Err(InvalidCharacter);
+ }
+
+ // Step 3.
+ Ok(ProcessingInstruction::new(target, data, abstract_self))
+ }
+
pub fn CreateEvent(&self, interface: DOMString) -> Fallible<AbstractEvent> {
match interface.as_slice() {
"UIEvents" => Ok(UIEvent::new(self.window)),