From cd260975454d38c77016680f3582014abb2a8618 Mon Sep 17 00:00:00 2001 From: Claudia Meadows Date: Wed, 30 Oct 2024 13:09:01 -0700 Subject: [PATCH] Revise an outdated comment, cheat a little bit on redraw context --- src/core.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/core.js b/src/core.js index df272ece3..d5b8cddc3 100644 --- a/src/core.js +++ b/src/core.js @@ -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} = {}) => { @@ -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})