This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function updateEvent(vnode, key, value) { | |
if (vnode.events != null) { | |
if (vnode.events[key] === value) return | |
if (value != null && (typeof value === "function" || typeof value === "object")) { | |
if (vnode.events[key] == null) vnode.dom.addEventListener(key.slice(2), vnode.events, false) | |
vnode.events[key] = value | |
} | |
// ... | |
} | |
// ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
m.render(document.getElementById('app'), | |
m('form', { | |
onreset: (e) => { | |
console.log('resetting form...') | |
}, | |
onsubmit: (e) => { | |
e.preventDefault(); | |
console.log('submitting form...') | |
}, | |
}, [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
m.render(document.getElementById('app'), | |
m('form', { | |
onsubmit: (e) => { | |
e.preventDefault(); | |
console.log('I am on the form element') | |
} | |
}, [ | |
m('button', { type: 'submit'}, 'Submit') | |
]) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.defineProperty(Object.prototype, "onsubmit", { | |
get() { | |
return (e) => { | |
e.preventDefault(); | |
console.log('I am on the setter'); | |
} | |
}, | |
set(val) { | |
console.log(val); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.prototype.onsubmit = 1 |
OlderNewer