mirror of
https://github.com/servo/servo.git
synced 2025-06-21 23:59:00 +01:00
Implement DOMImplementation::createDocumentType
Implementation according to spec: http://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype Closes #1489.
This commit is contained in:
parent
c876335d22
commit
0d35d4932b
3 changed files with 35 additions and 3 deletions
|
@ -14,9 +14,9 @@
|
||||||
interface DOMImplementation {
|
interface DOMImplementation {
|
||||||
/*boolean hasFeature(DOMString feature,
|
/*boolean hasFeature(DOMString feature,
|
||||||
[TreatNullAs=EmptyString] DOMString version);*/
|
[TreatNullAs=EmptyString] DOMString version);*/
|
||||||
/*[Throws]
|
[Creator, Throws]
|
||||||
DocumentType createDocumentType(DOMString qualifiedName, DOMString publicId,
|
DocumentType createDocumentType(DOMString qualifiedName, DOMString publicId,
|
||||||
DOMString systemId);*/
|
DOMString systemId);
|
||||||
/*[Throws]
|
/*[Throws]
|
||||||
Document createDocument(DOMString? namespace,
|
Document createDocument(DOMString? namespace,
|
||||||
[TreatNullAs=EmptyString] DOMString qualifiedName,
|
[TreatNullAs=EmptyString] DOMString qualifiedName,
|
||||||
|
|
|
@ -3,7 +3,11 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use dom::bindings::codegen::DOMImplementationBinding;
|
use dom::bindings::codegen::DOMImplementationBinding;
|
||||||
use dom::bindings::utils::{Reflector, Reflectable, reflect_dom_object};
|
use dom::bindings::utils::{DOMString, Reflector, Reflectable, reflect_dom_object};
|
||||||
|
use dom::bindings::utils::{Fallible, InvalidCharacter, NamespaceError};
|
||||||
|
use dom::bindings::utils::{QName, Name, InvalidXMLName, xml_name_type};
|
||||||
|
use dom::documenttype::DocumentType;
|
||||||
|
use dom::node::AbstractNode;
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
|
|
||||||
pub struct DOMImplementation {
|
pub struct DOMImplementation {
|
||||||
|
@ -34,3 +38,20 @@ impl Reflectable for DOMImplementation {
|
||||||
&mut self.reflector_
|
&mut self.reflector_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// http://dom.spec.whatwg.org/#domimplementation
|
||||||
|
impl DOMImplementation {
|
||||||
|
// http://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype
|
||||||
|
pub fn CreateDocumentType(&self, qname: DOMString, pubid: DOMString, sysid: DOMString) -> Fallible<AbstractNode> {
|
||||||
|
// FIXME: To be removed in https://github.com/mozilla/servo/issues/1498
|
||||||
|
let force_quirks : bool = false;
|
||||||
|
match xml_name_type(qname) {
|
||||||
|
// Step 1.
|
||||||
|
InvalidXMLName => Err(InvalidCharacter),
|
||||||
|
// Step 2.
|
||||||
|
Name => Err(NamespaceError),
|
||||||
|
// Step 3.
|
||||||
|
QName => Ok(DocumentType::new(qname, Some(pubid), Some(sysid), force_quirks, self.owner.Document()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -11,6 +11,17 @@
|
||||||
is(document.implementation, implementation, "test1-2, basic test");
|
is(document.implementation, implementation, "test1-2, basic test");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// test2: createDocumentType
|
||||||
|
{
|
||||||
|
is(document.doctype, null, "test2-0, createDocumentType");
|
||||||
|
|
||||||
|
var doctype = document.implementation.createDocumentType("html", null, null);
|
||||||
|
is_a(doctype && doctype, DocumentType, "test2-1, createDocumentType");
|
||||||
|
|
||||||
|
doctype = document.implementation.createDocumentType("html:html", null, null);
|
||||||
|
is_a(doctype && doctype, DocumentType, "test2-2, createDocumentType");
|
||||||
|
}
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue