Unbreak accidental back-compat break with event optimization (#2222)

This was supposed to be purely additive. See here for more details:

https://github.com/MithrilJS/mithril.js/pull/1949#issuecomment-417824513
This commit is contained in:
Isiah Meadows 2018-09-18 10:14:21 -04:00 committed by GitHub
parent f4ddcc4b24
commit c703b03253
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 80 additions and 11 deletions

View file

@ -1182,13 +1182,20 @@ var coreRenderer = function($window) {
// 4. The event name is remapped to the handler0 before calling it.
// 5. In function-based event handlers, `ev.target === this`. We replicate
// that below.
// 6. In function-based event handlers, `return false` prevents the default
// action and stops event propagation. We replicate that below.
function EventDict() {}
EventDict.prototype = Object.create(null)
EventDict.prototype.handleEvent = function (ev) {
var handler0 = this["on" + ev.type]
if (typeof handler0 === "function") handler0.call(ev.target, ev)
var result
if (typeof handler0 === "function") result = handler0.call(ev.target, ev)
else if (typeof handler0.handleEvent === "function") handler0.handleEvent(ev)
if (typeof onevent === "function") onevent.call(ev.target, ev)
if (result === false) {
ev.preventDefault()
ev.stopPropagation()
}
}
//event
function updateEvent(vnode, key2, value) {