-
-
Notifications
You must be signed in to change notification settings - Fork 929
Closed
Labels
Area: CoreFor anything dealing with Mithril core itselfFor anything dealing with Mithril core itselfType: Breaking ChangeFor any feature request or suggestion that could reasonably break existing codeFor any feature request or suggestion that could reasonably break existing codeType: EnhancementFor any feature request or suggestion that isn't a bug fixFor any feature request or suggestion that isn't a bug fix
Description
Mithril version:
Platform and OS:
Project:
Is this something you're interested in implementing yourself? Very
Description
Replace this pattern:
const Comp = {
onbeforeupdate(vnode, old) {
return cond
},
view(vnode) {
return tree
}
}
With this:
const Comp = {
// On first render, `old` is not passed
view(vnode, old) {
if (!cond) return m.retain()
return tree
}
}
m.retain()
would have a tag
of "="
, and that's how we'd detect. This can be used anywhere a child is, and on first render would be equivalent to undefined
(you're essentially explicitly "retaining" no tree, so it's consistent).
Why
It's simpler for us to implement and simpler for users to implement. It's also more flexible.
This is something we've wanted to do for a while.
Possible Implementation
- Modify
createVnode
to do nothing onvnode.tag === "="
. - Modify
updateVnode
to, onvnode.tag === "="
, transfer state much like whatshouldNotUpdate
does when preventing update, but also transfer tags and attributes, in effect modifying them.retain()
vnode to be the actual desired vnode. (This avoids having to replace nodes in the tree, which makes this a lot less complicated.) - Remove the
shouldNotUpdate
check inupdateNode
. - Modify
updateComponent
to invokevnode.state.view(vnode, old)
.
Open Questions
gilbert, StephanHoyer, barneycarroll and AjBreidenbachgilbert and AjBreidenbach
Metadata
Metadata
Assignees
Labels
Area: CoreFor anything dealing with Mithril core itselfFor anything dealing with Mithril core itselfType: Breaking ChangeFor any feature request or suggestion that could reasonably break existing codeFor any feature request or suggestion that could reasonably break existing codeType: EnhancementFor any feature request or suggestion that isn't a bug fixFor any feature request or suggestion that isn't a bug fix
Type
Projects
Status
Completed/Declined