Skip to content

Commit

Permalink
Merge pull request #80 from JackCA/fix-option-destroy-without-select
Browse files Browse the repository at this point in the history
Fix issue with unregisterOption (with Test)
  • Loading branch information
Robdel12 committed Nov 4, 2015
2 parents 40d98c6 + b43731d commit 195841a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
5 changes: 4 additions & 1 deletion addon/components/x-option.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ export default Ember.Component.extend({
*/
willDestroyElement: function() {
this._super.apply(this, arguments);
this.get('select').unregisterOption(this);
let select = this.get('select');
if(select) {
select.unregisterOption(this);
}
}
});
23 changes: 23 additions & 0 deletions tests/unit/components/x-option-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* jshint expr:true */
import { expect } from 'chai';
import {
describeComponent,
it
} from 'ember-mocha';


describeComponent(
'x-option',
'XOptionComponent',
{
needs: []
},
function() {
it('does not blow up when destroyed before rendered', function() {
var component = this.subject();
expect(function() {
component.willDestroyElement();
}).not.to.throw();
});
}
);

0 comments on commit 195841a

Please sign in to comment.