mirror of
https://github.com/servo/servo.git
synced 2025-06-24 09:04:33 +01:00
Implement document.createProcessingInstruction
Spec: http://dom.spec.whatwg.org/#dom-document-createprocessinginstruction This is a sub-task for #1428.
This commit is contained in:
parent
799e0ace78
commit
ac8c659d2b
4 changed files with 39 additions and 2 deletions
|
@ -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)),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue