Permalink
Browse files

Merge pull request #2203 from ibolmo/fix-2170-ie-Element-Event-change…

…-propertychange

Fix 2170 ie element event change propertychange
  • Loading branch information...
2 parents d05c9fb + af074d3 commit bc7009653bfa5156129540228449e2901649b026 @ibolmo ibolmo committed Jan 18, 2012
Showing with 29 additions and 1 deletion.
  1. +1 −1 Source/Element/Element.Event.js
  2. +28 −0 Specs/1.4client/Element/Element.Event.js
@@ -175,7 +175,7 @@ if (!window.addEventListener){
return (this.get('tag') == 'input' && (type == 'radio' || type == 'checkbox')) ? 'propertychange' : 'change'
},
condition: function(event){
- return !!(this.type != 'radio' || this.checked);
+ return this.type != 'radio' || (event.event.propertyName == 'checked' && this.checked);
}
}
}
@@ -82,4 +82,32 @@ describe('Element.Event', function(){
});
+describe('Element.Event.change', function(){
+
+ it('should not fire "change" for any property', function(){
+ var callback = jasmine.createSpy('Element.Event.change');
+
+ var input = new Element('input', {
+ 'type': 'radio',
+ 'class': 'someClass',
+ 'checked': 'checked'
+ }).addEvent('change', callback).inject(document.body);
+
+ input.removeClass('someClass');
+ expect(callback).not.toHaveBeenCalled();
+
+ var text = new Element('input', {
+ 'type': 'text',
+ 'class': 'otherClass',
+ 'value': 'text value'
+ }).addEvent('change', callback).inject(document.body);
+
+ text.removeClass('otherClass');
+ expect(callback).not.toHaveBeenCalled();
+
+ [input, text].invoke('destroy');
+ });
+
+});
+
})();

0 comments on commit bc70096

Please sign in to comment.