aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/domimplementation.rs
diff options
context:
space:
mode:
authorcjkenned <cam.j.kennedy@gmail.com>2016-04-24 10:12:15 -0600
committercjkenned <cam.j.kennedy@gmail.com>2016-04-28 20:26:54 -0600
commitd9128fba07c65bde012c3fb9f5948386f4f3da39 (patch)
treefaca3fb7f07845738eed56e53986aee035398c8e /components/script/dom/domimplementation.rs
parentf932db34c85dcd65a46ddde3ce0d8f6c92c28b7b (diff)
downloadservo-d9128fba07c65bde012c3fb9f5948386f4f3da39.tar.gz
servo-d9128fba07c65bde012c3fb9f5948386f4f3da39.zip
[10743] Add content type to XmlDocument constructor based on namespace
[10743] Fix namespace in createDocument test [10743] Remove test ini file, match returns static strings instead of DOMString. [10743] Fix arguments to XMLDocument::new Update failing test [10743] Add content type to XmlDocument constructor based on namespace [10743] Fix namespace in createDocument test [10743] Remove test ini file, match returns static strings instead of DOMString. [10743] Fix arguments to XMLDocument::new Update failing test
Diffstat (limited to 'components/script/dom/domimplementation.rs')
-rw-r--r--components/script/dom/domimplementation.rs15
1 files changed, 11 insertions, 4 deletions
diff --git a/components/script/dom/domimplementation.rs b/components/script/dom/domimplementation.rs
index 37b75688c2b..8c0f9bd61ee 100644
--- a/components/script/dom/domimplementation.rs
+++ b/components/script/dom/domimplementation.rs
@@ -12,7 +12,7 @@ use dom::bindings::global::GlobalRef;
use dom::bindings::inheritance::Castable;
use dom::bindings::js::{JS, Root};
use dom::bindings::reflector::{Reflector, reflect_dom_object};
-use dom::bindings::xmlname::validate_qualified_name;
+use dom::bindings::xmlname::{validate_qualified_name, namespace_from_domstring};
use dom::document::DocumentSource;
use dom::document::{Document, IsHTMLDocument};
use dom::documenttype::DocumentType;
@@ -62,19 +62,26 @@ impl DOMImplementationMethods for DOMImplementation {
// https://dom.spec.whatwg.org/#dom-domimplementation-createdocument
fn CreateDocument(&self,
- namespace: Option<DOMString>,
+ maybe_namespace: Option<DOMString>,
qname: DOMString,
maybe_doctype: Option<&DocumentType>)
-> Fallible<Root<XMLDocument>> {
let win = self.document.window();
let loader = DocumentLoader::new(&self.document.loader());
+ let namespace = namespace_from_domstring(maybe_namespace.to_owned());
+
+ let content_type = match namespace {
+ ns!(html) => "application/xhtml+xml",
+ ns!(svg) => "image/svg+xml",
+ _ => "application/xml"
+ };
// Step 1.
let doc = XMLDocument::new(win,
None,
None,
IsHTMLDocument::NonHTMLDocument,
- None,
+ Some(DOMString::from(content_type)),
None,
DocumentSource::NotFromParser,
loader);
@@ -82,7 +89,7 @@ impl DOMImplementationMethods for DOMImplementation {
let maybe_elem = if qname.is_empty() {
None
} else {
- match doc.upcast::<Document>().CreateElementNS(namespace, qname) {
+ match doc.upcast::<Document>().CreateElementNS(maybe_namespace, qname) {
Err(error) => return Err(error),
Ok(elem) => Some(elem),
}