Merge pull request #1873 from pygy/fix-1872
Take the namespace of the root node into account, fix other ns oversight #1872
This commit is contained in:
commit
18d732bf57
2 changed files with 9 additions and 2 deletions
|
|
@ -146,7 +146,7 @@ module.exports = function($window) {
|
||||||
//update
|
//update
|
||||||
function updateNodes(parent, old, vnodes, recycling, hooks, nextSibling, ns) {
|
function updateNodes(parent, old, vnodes, recycling, hooks, nextSibling, ns) {
|
||||||
if (old === vnodes || old == null && vnodes == null) return
|
if (old === vnodes || old == null && vnodes == null) return
|
||||||
else if (old == null) createNodes(parent, vnodes, 0, vnodes.length, hooks, nextSibling, undefined)
|
else if (old == null) createNodes(parent, vnodes, 0, vnodes.length, hooks, nextSibling, ns)
|
||||||
else if (vnodes == null) removeNodes(old, 0, old.length, vnodes)
|
else if (vnodes == null) removeNodes(old, 0, old.length, vnodes)
|
||||||
else {
|
else {
|
||||||
if (old.length === vnodes.length) {
|
if (old.length === vnodes.length) {
|
||||||
|
|
@ -613,12 +613,13 @@ module.exports = function($window) {
|
||||||
if (!dom) throw new Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.")
|
if (!dom) throw new Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.")
|
||||||
var hooks = []
|
var hooks = []
|
||||||
var active = $doc.activeElement
|
var active = $doc.activeElement
|
||||||
|
var namespace = dom.namespaceURI
|
||||||
|
|
||||||
// First time rendering into a node clears it out
|
// First time rendering into a node clears it out
|
||||||
if (dom.vnodes == null) dom.textContent = ""
|
if (dom.vnodes == null) dom.textContent = ""
|
||||||
|
|
||||||
if (!Array.isArray(vnodes)) vnodes = [vnodes]
|
if (!Array.isArray(vnodes)) vnodes = [vnodes]
|
||||||
updateNodes(dom, dom.vnodes, Vnode.normalizeChildren(vnodes), false, hooks, null, undefined)
|
updateNodes(dom, dom.vnodes, Vnode.normalizeChildren(vnodes), false, hooks, null, namespace === "http://www.w3.org/1999/xhtml" ? undefined : namespace)
|
||||||
dom.vnodes = vnodes
|
dom.vnodes = vnodes
|
||||||
for (var i = 0; i < hooks.length; i++) hooks[i]()
|
for (var i = 0; i < hooks.length; i++) hooks[i]()
|
||||||
if ($doc.activeElement !== active) active.focus()
|
if ($doc.activeElement !== active) active.focus()
|
||||||
|
|
|
||||||
|
|
@ -293,4 +293,10 @@ o.spec("render", function() {
|
||||||
o(svg.dom.childNodes[0].namespaceURI).equals("http://www.w3.org/2000/svg")
|
o(svg.dom.childNodes[0].namespaceURI).equals("http://www.w3.org/2000/svg")
|
||||||
o(svg.dom.childNodes[1].namespaceURI).equals("http://www.w3.org/2000/svg")
|
o(svg.dom.childNodes[1].namespaceURI).equals("http://www.w3.org/2000/svg")
|
||||||
})
|
})
|
||||||
|
o("the namespace of the root is passed to children", function() {
|
||||||
|
render(root, [{tag: "svg"}])
|
||||||
|
o(root.childNodes[0].namespaceURI).equals("http://www.w3.org/2000/svg")
|
||||||
|
render(root.childNodes[0], [{tag: "g"}])
|
||||||
|
o(root.childNodes[0].childNodes[0].namespaceURI).equals("http://www.w3.org/2000/svg")
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue