Browse files

Optimized the Element.Event.change condition. Added coverage non-radi…

…o inputs.
  • Loading branch information...
1 parent 5fa8489 commit af074d305bac62db9e4528e6377ca5873c6ab8da @ibolmo ibolmo committed Jan 18, 2012
Showing with 11 additions and 2 deletions.
  1. +1 −1 Source/Element/Element.Event.js
  2. +10 −1 Specs/1.4client/Element/Element.Event.js
View
2 Source/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 event.type == 'change' || !!this.checked && event.type == 'propertychange' && event.event.propertyName == 'checked';
+ return this.type != 'radio' || (event.event.propertyName == 'checked' && this.checked);
}
}
}
View
11 Specs/1.4client/Element/Element.Event.js
@@ -96,7 +96,16 @@ describe('Element.Event.change', function(){
input.removeClass('someClass');
expect(callback).not.toHaveBeenCalled();
- input.destroy();
+ 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 af074d3

Please sign in to comment.