Skip to content

Commit

Permalink
Merge pull request #10 from enspandi/master
Browse files Browse the repository at this point in the history
- add name to attribute bindings to specify a form element name
  • Loading branch information
cowboyd committed Apr 7, 2015
2 parents 46b7850 + 359c2ed commit c4b8225
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion addon/components/x-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var isArray = Ember.isArray;
export default Ember.Component.extend({
tagName: "select",
classNameBindings: [":x-select"],
attributeBindings: ['disabled', 'tabindex', 'multiple'],
attributeBindings: ['disabled', 'tabindex', 'multiple', 'name', 'autofocus', 'form', 'required', 'size'],

/**
* Bound to the `disabled` attribute on the native <select> tag.
Expand Down
27 changes: 27 additions & 0 deletions tests/acceptance/x-select-single-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,31 @@ describe('XSelect: Single Selection', function() {
});
});

describe('native select element attributes', function() {
beforeEach(function() {
controller.setProperties({
attrName: 'person-select',
attrForm: 'person-form',
attrSize: '3',
isRequired: true,
hasAutofocus: true
});
});
it('renders the name attribute', function() {
expect(this.$().attr('name')).to.equal('person-select');
});
it('renders the form attribute', function() {
expect(this.$().attr('form')).to.equal('person-form');
});
it('renders the size attribute', function() {
expect(this.$().attr('size')).to.equal('3');
});
it('renders the required attribute', function() {
expect(this.$().attr('required')).to.equal('required');
});
it('renders the autofocus attribute', function() {
expect(this.$().attr('autofocus')).to.equal('autofocus');
});
});

});
6 changes: 6 additions & 0 deletions tests/dummy/app/controllers/single.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import Folks from 'dummy/mixins/folks';

export default Ember.ObjectController.extend(Folks, {
isDisabled: false,
isRequired: false,
hasAutofocus: false,
attrName: null,
attrForm: null,
attrSize: null,

actions: {
tagYouAreIt: function(object) {
this.tagged = object;
Expand Down
2 changes: 1 addition & 1 deletion tests/dummy/app/templates/single.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p>
{{#x-select value=it action="tagYouAreIt" disabled=isDisabled}}
{{#x-select value=it action="tagYouAreIt" disabled=isDisabled required=isRequired autofocus=hasAutofocus name=attrName form=attrForm size=attrSize}}
{{#x-option value=charles}}Charles{{/x-option}}
{{#x-option value=bastion}}Bastion{{/x-option}}
{{#x-option value=stanley}}Stanley{{/x-option}}
Expand Down

0 comments on commit c4b8225

Please sign in to comment.