Skip to content

Commit

Permalink
works with inputs without the form-control class
Browse files Browse the repository at this point in the history
  • Loading branch information
paulyoder committed Jan 13, 2015
1 parent a7b79f5 commit e93c512
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/showErrors.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ showErrorsModule.directive 'showErrors',
showSuccess = getShowSuccess options
trigger = getTrigger options

inputEl = el[0].querySelector '.form-control[name]'
inputEl = el[0].querySelector 'input[name]'
inputNgEl = angular.element inputEl
inputName = $interpolate(inputNgEl.attr('name') || '')(scope)
unless inputName
throw "show-errors element has no child input elements with a 'name' attribute and a 'form-control' class"
throw "show-errors element has no child input element with a 'name' attribute"

inputNgEl.bind trigger, ->
blurred = true
Expand Down
4 changes: 2 additions & 2 deletions src/showErrors.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
options = scope.$eval(attrs.showErrors);
showSuccess = getShowSuccess(options);
trigger = getTrigger(options);
inputEl = el[0].querySelector('.form-control[name]');
inputEl = el[0].querySelector('input[name]');
inputNgEl = angular.element(inputEl);
inputName = $interpolate(inputNgEl.attr('name') || '')(scope);
if (!inputName) {
throw "show-errors element has no child input elements with a 'name' attribute and a 'form-control' class";
throw "show-errors element has no child input element with a 'name' attribute";
}
inputNgEl.bind(trigger, function() {
blurred = true;
Expand Down
4 changes: 2 additions & 2 deletions src/showErrors.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions test/showErrors.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ describe 'showErrors', ->
$scope.$digest()
el

describe 'directive does not contain an input element with a form-control class and name attribute', ->
describe 'directive does not contain an input element with a "name" attribute', ->
it 'throws an exception', ->
expect( ->
$compile('<form name="userForm"><div class="form-group" show-errors><input type="text" name="firstName"></input></div></form>')($scope)
).toThrow "show-errors element has no child input elements with a 'name' attribute and a 'form-control' class"
$compile('<form name="userForm"><div class="form-group" show-errors><input type="text" ></input></div></form>')($scope)
).toThrow "show-errors element has no child input element with a 'name' attribute"

it "throws an exception if the element doesn't have the form-group or input-group class", ->
expect( ->
Expand Down
6 changes: 3 additions & 3 deletions test/showErrors.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
$scope.$digest();
return el;
};
describe('directive does not contain an input element with a form-control class and name attribute', function() {
describe('directive does not contain an input element with a "name" attribute', function() {
return it('throws an exception', function() {
return expect(function() {
return $compile('<form name="userForm"><div class="form-group" show-errors><input type="text" name="firstName"></input></div></form>')($scope);
}).toThrow("show-errors element has no child input elements with a 'name' attribute and a 'form-control' class");
return $compile('<form name="userForm"><div class="form-group" show-errors><input type="text" ></input></div></form>')($scope);
}).toThrow("show-errors element has no child input element with a 'name' attribute");
});
});
it("throws an exception if the element doesn't have the form-group or input-group class", function() {
Expand Down

0 comments on commit e93c512

Please sign in to comment.