aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/script')
-rw-r--r--src/components/script/dom/bindings/codegen/Bindings.conf1
-rw-r--r--src/components/script/dom/document.rs18
-rw-r--r--src/components/script/dom/webidls/Document.webidl4
3 files changed, 21 insertions, 2 deletions
diff --git a/src/components/script/dom/bindings/codegen/Bindings.conf b/src/components/script/dom/bindings/codegen/Bindings.conf
index 7f2a38a5143..b9fd8d9c1d8 100644
--- a/src/components/script/dom/bindings/codegen/Bindings.conf
+++ b/src/components/script/dom/bindings/codegen/Bindings.conf
@@ -154,6 +154,7 @@ DOMInterfaces = {
'createComment',
'createDocumentFragment',
'createElement',
+ 'createProcessingInstruction',
'createTextNode',
'title',
'body',
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)),
diff --git a/src/components/script/dom/webidls/Document.webidl b/src/components/script/dom/webidls/Document.webidl
index 975fac355e2..a3b1c41648b 100644
--- a/src/components/script/dom/webidls/Document.webidl
+++ b/src/components/script/dom/webidls/Document.webidl
@@ -50,8 +50,8 @@ interface Document : Node {
Text createTextNode(DOMString data);
[Creator]
Comment createComment(DOMString data);
- /*[Creator, Throws]
- ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data);*/
+ [Creator, Throws]
+ ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data);
/*[Throws]
Node importNode(Node node, optional boolean deep = true);