Skip to content

Commit

Permalink
Revise an outdated comment, cheat a little bit on redraw context
Browse files Browse the repository at this point in the history
  • Loading branch information
dead-claudia committed Oct 30, 2024
1 parent 814261f commit cd26097
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1083,16 +1083,14 @@ var setAttr = (vnode, element, mask, key, old, attrs) => {
// 4. The event name is remapped to the handler before calling it.
// 5. In function-based event handlers, `ev.currentTarget === this`. We replicate that below.
// 6. In function-based event handlers, `return false` prevents the default action and stops event
// propagation. Instead of that, we hijack it to control implicit redrawing, and let users
// return a promise that resolves to it.
// propagation. Instead of that, we hijack the return value, so we can have it auto-redraw if
// the user returns `"skip-redraw"` or a promise that resolves to it.
class EventDict extends Map {
async handleEvent(ev) {
invokeRedrawable(this._, this.get(`on${ev.type}`), ev.currentTarget, ev)
}
}

//event

var currentlyRendering = []

m.render = (dom, vnode, {redraw, removeOnThrow} = {}) => {
Expand Down Expand Up @@ -1175,9 +1173,8 @@ m.mount = (root, view) => {
}
}
var redraw = () => { if (!id) id = window.requestAnimationFrame(redraw.sync) }
var Mount = function (_, old) {
return [m.remove(unschedule), view.call(this, !old)]
}
// Cheating with context access for a minor bundle size win.
var Mount = (_, old) => [m.remove(unschedule), view.call(currentContext, !old)]
redraw.sync = () => {
unschedule()
m.render(root, m(Mount), {redraw})
Expand Down

0 comments on commit cd26097

Please sign in to comment.