Reduce memory allocation/usage across multiple event handlers
- `handleEvent` is a very useful tool. - Always use `addEventListener`/`removeEventListener`, since it's required for this optimization. - Change log updated. - Drive-by: make DOM mock work with both event listener types. - Drive-by: eliminate possibility of `Object.prototype` interference.
This commit is contained in:
parent
164fa5615b
commit
dbbdb0664a
3 changed files with 30 additions and 17 deletions
|
|
@ -278,7 +278,9 @@ module.exports = function(options) {
|
|||
e.target = this
|
||||
if (events[e.type] != null) {
|
||||
for (var i = 0; i < events[e.type].length; i++) {
|
||||
events[e.type][i].call(this, e)
|
||||
var handler = events[e.type][i]
|
||||
if (typeof handler === "function") handler.call(this, e)
|
||||
else handler.handleEvent(e)
|
||||
}
|
||||
}
|
||||
e.preventDefault = function() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue