Skip to content

Commit

Permalink
createElement now sets namespace from contentType (#2826)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayg authored and zcorpan committed Apr 19, 2016
1 parent 3b85872 commit 3219251
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions dom/nodes/Document-createElement-namespace.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
*/

/**
* Test that an element created using the Document object doc has the HTML
* namespace.
* Test that an element created using the Document object doc has the namespace
* that would be expected for the given contentType.
*/
function testDoc(doc, contentType) {
if (doc.contentType !== undefined) {
Expand All @@ -23,7 +23,11 @@
"Wrong MIME type -- incorrect server config?");
}

assert_equals(doc.createElement("x").namespaceURI, "http://www.w3.org/1999/xhtml");
var expectedNamespace = contentType == "text/html" ||
contentType == "application/xhtml+xml"
? "http://www.w3.org/1999/xhtml" : null;

assert_equals(doc.createElement("x").namespaceURI, expectedNamespace);
}

// First test various objects we create in JS
Expand All @@ -39,11 +43,11 @@
}, "Created element's namespace in created XML document");
test(function() {
testDoc(document.implementation.createDocument("http://www.w3.org/1999/xhtml", "html", null),
"application/xml");
"application/xhtml+xml");
}, "Created element's namespace in created XHTML document");
test(function() {
testDoc(document.implementation.createDocument("http://www.w3.org/2000/svg", "svg", null),
"application/xml");
"image/svg+xml");
}, "Created element's namespace in created SVG document");
test(function() {
testDoc(document.implementation.createDocument("http://www.w3.org/1998/Math/MathML", "math", null),
Expand Down

0 comments on commit 3219251

Please sign in to comment.