Chrome Seems To Define 'event' Variable In Meteor/blaze
Solution 1:
It's nothing to do with Meteor, just Chrome: Chrome does this to support code written originally for Internet Explorer; in addition to passing the event to the handler, it also sets it as a global event
variable.
Microsoft's "new" event handling in IE5 (or was it 5.5?) used a global event
object and attachEvent
/removeEvent
. Then DOM2 came along (after IE6 had been released) and defined addEventListener
/removeEventListener
where the event handler recieves the event as an argument. Then years passed before Microsoft supported DOM2 (in IE9).
So when Chrome was coming up, they made the decision to provide a global event
object to increase compatibility with IE-specific code. Mozilla chose not to originally, but does now; more in my answer here.
You can see it here — run this on Chrome:
document.getElementById("target").addEventListener("click", function(e) {
console.log("e === event? ", e === event);
}, false);
<divid="target">Click me</div>
As you can see, the global event
object and the event object the handler receives are the same object.
Post a Comment for "Chrome Seems To Define 'event' Variable In Meteor/blaze"