Skip to content

Commit

Permalink
Merge pull request #50 from mic4ael/close-button-type
Browse files Browse the repository at this point in the history
Prevent ENTER from triggering click events
  • Loading branch information
okcoker committed Mar 25, 2016
2 parents fde8ec6 + f762f2c commit 9176e1e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/taggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,7 @@

close.innerHTML = '×';
close.className = 'close';
close.type = 'button';
_on(close, 'click', this._remove.bind(this, close));

_setText(span, text);
Expand Down
16 changes: 16 additions & 0 deletions test/taggle-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -640,5 +640,21 @@ describe('Taggle', function() {
expect(this.instance.getTagValues().length).to.equal(1);
});
});

describe('#checkCloseButtonType', function() {
beforeEach(function() {
this.instance = new Taggle(this.container, {
tags: ['zero', 'one', 'two']
});
});

it('should have type equal to button', function() {
var elements = this.instance.getTagElements();
for (var i = 0; i < elements.length; ++i) {
var closeButton = elements[i].querySelector('button.close');
expect(closeButton).to.have.property('type').and.equal('button');
}
});
});
});
});

0 comments on commit 9176e1e

Please sign in to comment.