Skip to content

Commit d4b29dc

Browse files
committed
Revise an outdated comment, cheat a little bit on redraw context
1 parent 241885e commit d4b29dc

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/core.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,16 +1083,14 @@ var setAttr = (vnode, element, mask, key, old, attrs) => {
10831083
// 4. The event name is remapped to the handler before calling it.
10841084
// 5. In function-based event handlers, `ev.currentTarget === this`. We replicate that below.
10851085
// 6. In function-based event handlers, `return false` prevents the default action and stops event
1086-
// propagation. Instead of that, we hijack it to control implicit redrawing, and let users
1087-
// return a promise that resolves to it.
1086+
// propagation. Instead of that, we hijack the return value, so we can have it auto-redraw if
1087+
// the user returns `"skip-redraw"` or a promise that resolves to it.
10881088
class EventDict extends Map {
10891089
async handleEvent(ev) {
10901090
invokeRedrawable(this._, this.get(`on${ev.type}`), ev.currentTarget, ev)
10911091
}
10921092
}
10931093

1094-
//event
1095-
10961094
var currentlyRendering = []
10971095

10981096
m.render = (dom, vnode, {redraw, removeOnThrow} = {}) => {
@@ -1175,9 +1173,8 @@ m.mount = (root, view) => {
11751173
}
11761174
}
11771175
var redraw = () => { if (!id) id = window.requestAnimationFrame(redraw.sync) }
1178-
var Mount = function (_, old) {
1179-
return [m.remove(unschedule), view.call(this, !old)]
1180-
}
1176+
// Cheating with context access for a minor bundle size win.
1177+
var Mount = (_, old) => [m.remove(unschedule), view.call(currentContext, !old)]
11811178
redraw.sync = () => {
11821179
unschedule()
11831180
m.render(root, m(Mount), {redraw})

0 commit comments

Comments
 (0)