Skip to content

Commit

Permalink
fix(tagsInput): fix add-on-paste issue in IE
Browse files Browse the repository at this point in the history
Fix an error when pasting in IE. IE uses window.clipboardData
instead of putting clipboardData on the event itself.

Fixes mbenford#325.
  • Loading branch information
LoganBarnett committed Mar 13, 2015
1 parent 8359e60 commit 01b1e1e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/tags-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* @param {expression} onTagRemoving Expression to evaluate that will be invoked before removing a tag. The tag is available as $tag. This method must return either true or false. If false, the tag will not be removed.
* @param {expression} onTagRemoved Expression to evaluate upon removing an existing tag. The removed tag is available as $tag.
*/
tagsInput.directive('tagsInput', function($timeout, $document, tagsInputConfig, tiUtil) {
tagsInput.directive('tagsInput', function($timeout, $document, $window, tagsInputConfig, tiUtil) {
function TagList(options, events, onTagAdding, onTagRemoving) {
var self = {}, getTagText, setTagText, tagIsValid;

Expand Down Expand Up @@ -347,7 +347,13 @@ tagsInput.directive('tagsInput', function($timeout, $document, tagsInputConfig,
})
.on('input-paste', function(event) {
if (options.addOnPaste) {
var data = event.clipboardData.getData('text/plain');
var data;
if(event.clipboardData) {
data = event.clipboardData.getData('text/plain');
}
else {
data = $window.clipboardData.getData('Text');
}
var tags = data.split(options.pasteSplitPattern);
if (tags.length > 1) {
tags.forEach(function(tag) {
Expand Down

0 comments on commit 01b1e1e

Please sign in to comment.