Skip to content

Instantly share code, notes, and snippets.

@ibolmo
Created August 15, 2011 21:52
Show Gist options
  • Save ibolmo/1147965 to your computer and use it in GitHub Desktop.
Save ibolmo/1147965 to your computer and use it in GitHub Desktop.
/*<ltIE9>*/
if (!window.addEventListener){
var update = function(event){
event.target.store('$change:last', event.type);
};
Element.NativeEvents.propertychange = 2;
Element.Events.$change = {
base: 'change'
};
Element.Events.change = {
base: 'click',
condition: function(event){
var target = event.target;
return (event.type == 'change' || target.type == 'checkbox' || (target.type == 'radio' && target.retrieve('$change:last', '') == 'propertychange'));
},
onAdd: function(fn){
this.addEvents(this.retrieve('$change:events', {
keyup: update,
mouseup: update,
propertychange: update,
$change: function(event){
var type = event.target.type;
if (type != 'radio' && type != 'checkbox') fn.call(this, event);
}
}));
},
onRemove: function(){
this.removeEvents(this.retrieve('$change:events')).eliminate('$change:events');
}
};
}
/*</ltIE9>*/
@csuwildcat
Copy link

Christoph, bro, the regex sections are evaluated once per click (or even less in the _change case). Unless I can click 10,000 times a second, your comment is basically pedantic BS that will cause us to make the code more verbose.

@cpojer
Copy link

cpojer commented Aug 19, 2011

That is not the point. Regex is not meant for simple equality checks.

@csuwildcat
Copy link

csuwildcat commented Aug 19, 2011 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment