add docs for SVG, and better tests

This commit is contained in:
Leo Horie 2014-04-10 21:36:09 -04:00
parent 1aef5dd942
commit 5c9f9d782f
9 changed files with 100 additions and 9 deletions

View file

@ -487,6 +487,7 @@ mock.window = new function() {
this[name] = value.toString()
},
setAttributeNS: function(namespace, name, value) {
this.namespaceURI = namespace
this[name] = value.toString()
},
getAttribute: function(name, value) {
@ -495,7 +496,9 @@ mock.window = new function() {
}
}
window.document.createElementNS = function(namespace, tag) {
return window.document.createElement(tag)
var element = window.document.createElement(tag)
element.namespaceURI = namespace
return element
}
window.document.createTextNode = function(text) {
return {nodeValue: text.toString()}
@ -665,7 +668,8 @@ function testMithril(mock) {
test(function() {
var root = mock.document.createElement("div")
m.render(root, m("svg", [m("g")]))
return root.childNodes[0].childNodes[0].nodeName === "G"
var g = root.childNodes[0].childNodes[0]
return g.nodeName === "G" && g.namespaceURI == "http://www.w3.org/2000/svg"
})
test(function() {
var root = mock.document.createElement("div")