diff --git a/Source/Forms/Form.Validator.js b/Source/Forms/Form.Validator.js index 0bc2292b..ac996492 100644 --- a/Source/Forms/Form.Validator.js +++ b/Source/Forms/Form.Validator.js @@ -212,7 +212,7 @@ Form.Validator = new Class({ if (validators && !this.hasValidator(field,'warnOnly')){ if (passed){ field.addClass('validation-passed').removeClass('validation-failed'); - this.fireEvent('elementPass', field); + this.fireEvent('elementPass', [field]); } else { field.addClass('validation-failed').removeClass('validation-passed'); this.fireEvent('elementFail', [field, validatorsFailed]); diff --git a/Specs/1.3/Forms/Form.Validator.js b/Specs/1.3/Forms/Form.Validator.js index 51446d90..6d0a66fc 100644 --- a/Specs/1.3/Forms/Form.Validator.js +++ b/Specs/1.3/Forms/Form.Validator.js @@ -1,5 +1,36 @@ describe('Form.Validator', function(){ + describe('onElementPass', function(){ + + var form, select; + beforeEach(function(){ + form = new Element('form', { + action: '#' + }).adopt( + select = new Element('select', { + 'class': 'minLength:2' + }).adopt( + [1, 2, 3].map(function(item){ + return new Element('option', {html: item, value: item}); + }) + ) + ); + }); + + afterEach(function(){ + form = select = null; + }); + + it('should pass the field as an argument', function(){ + var spy = jasmine.createSpy(); + new Form.Validator(form, { + onElementPass: spy + }).validate(); + expect(spy).toHaveBeenCalledWith(select); + }); + + }); + describe('Validators', function(){ getValidator = Form.Validator.getValidator.bind(Form.Validator);