parent
3fd1953143
commit
6e57a0691c
2 changed files with 63 additions and 3 deletions
|
|
@ -189,9 +189,11 @@ module.exports = function($window, mountRedraw) {
|
||||||
// Remove these so they don't get overwritten
|
// Remove these so they don't get overwritten
|
||||||
var attrs = {}, onclick, href
|
var attrs = {}, onclick, href
|
||||||
assign(attrs, vnode.attrs)
|
assign(attrs, vnode.attrs)
|
||||||
attrs.component = null
|
// The first two are internal, but the rest are magic attributes
|
||||||
attrs.options = null
|
// that need censored to not screw up rendering.
|
||||||
attrs.key = null
|
attrs.component = attrs.options = attrs.key = attrs.oninit =
|
||||||
|
attrs.oncreate = attrs.onbeforeupdate = attrs.onupdate =
|
||||||
|
attrs.onbeforeremove = attrs.onremove = null
|
||||||
|
|
||||||
// Do this now so we can get the most current `href` and `disabled`.
|
// Do this now so we can get the most current `href` and `disabled`.
|
||||||
// Those attributes may also be specified in the selector, and we
|
// Those attributes may also be specified in the selector, and we
|
||||||
|
|
|
||||||
|
|
@ -550,6 +550,64 @@ o.spec("route", function() {
|
||||||
o(root.firstChild.firstChild.nodeValue).equals("text")
|
o(root.firstChild.firstChild.nodeValue).equals("text")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
o("route.Link keeps magic attributes from being double-called", function() {
|
||||||
|
$window = browserMock(env)
|
||||||
|
var render = coreRenderer($window)
|
||||||
|
route = apiRouter(null, null)
|
||||||
|
route.prefix = prefix
|
||||||
|
root = $window.document.body
|
||||||
|
|
||||||
|
var oninit = o.spy()
|
||||||
|
var oncreate = o.spy()
|
||||||
|
var onbeforeupdate = o.spy()
|
||||||
|
var onupdate = o.spy()
|
||||||
|
var onbeforeremove = o.spy()
|
||||||
|
var onremove = o.spy()
|
||||||
|
|
||||||
|
render(root, m(route.Link, {
|
||||||
|
href: "/test",
|
||||||
|
oninit: oninit,
|
||||||
|
oncreate: oncreate,
|
||||||
|
onbeforeupdate: onbeforeupdate,
|
||||||
|
onupdate: onupdate,
|
||||||
|
onbeforeremove: onbeforeremove,
|
||||||
|
onremove: onremove,
|
||||||
|
}, "text"))
|
||||||
|
|
||||||
|
o(oninit.callCount).equals(1)
|
||||||
|
o(oncreate.callCount).equals(1)
|
||||||
|
o(onbeforeupdate.callCount).equals(0)
|
||||||
|
o(onupdate.callCount).equals(0)
|
||||||
|
o(onbeforeremove.callCount).equals(0)
|
||||||
|
o(onremove.callCount).equals(0)
|
||||||
|
|
||||||
|
render(root, m(route.Link, {
|
||||||
|
href: "/test",
|
||||||
|
oninit: oninit,
|
||||||
|
oncreate: oncreate,
|
||||||
|
onbeforeupdate: onbeforeupdate,
|
||||||
|
onupdate: onupdate,
|
||||||
|
onbeforeremove: onbeforeremove,
|
||||||
|
onremove: onremove,
|
||||||
|
}, "text"))
|
||||||
|
|
||||||
|
o(oninit.callCount).equals(1)
|
||||||
|
o(oncreate.callCount).equals(1)
|
||||||
|
o(onbeforeupdate.callCount).equals(1)
|
||||||
|
o(onupdate.callCount).equals(1)
|
||||||
|
o(onbeforeremove.callCount).equals(0)
|
||||||
|
o(onremove.callCount).equals(0)
|
||||||
|
|
||||||
|
render(root, [])
|
||||||
|
|
||||||
|
o(oninit.callCount).equals(1)
|
||||||
|
o(oncreate.callCount).equals(1)
|
||||||
|
o(onbeforeupdate.callCount).equals(1)
|
||||||
|
o(onupdate.callCount).equals(1)
|
||||||
|
o(onbeforeremove.callCount).equals(1)
|
||||||
|
o(onremove.callCount).equals(1)
|
||||||
|
})
|
||||||
|
|
||||||
o("route.Link can render other tag without routes or dom access", function() {
|
o("route.Link can render other tag without routes or dom access", function() {
|
||||||
$window = browserMock(env)
|
$window = browserMock(env)
|
||||||
var render = coreRenderer($window)
|
var render = coreRenderer($window)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue